Skip to content

Commit

Permalink
Rewrite raw pointer fields to use raw_ptr<T> for cros
Browse files Browse the repository at this point in the history
This reapplies the rewrite_raw_ptr_fields rewriter on cros platform.

This change is a merge of the following changes:
PS1 raw_ptr rewrite generated by
    rewrite-multiple-platforms.sh cros
    on 80b0368
    with crrev.com/c/3726431
PS2 Unrewrite and exclude field in base/check.h to avoid cyclic include
PS3 Fix compile errors caused by NULL
PS4 Add missing .get()
PS5 Add missing .get()

Bug: 1073933
Change-Id: Ia042236c6c39f22ea1c96cb5b14ea68961c10534
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3731468
Reviewed-by: Bartek Nowierski <bartekn@chromium.org>
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Owners-Override: Keishi Hattori <keishi@chromium.org>
Owners-Override: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1018553}
  • Loading branch information
Keishi Hattori authored and Chromium LUCI CQ committed Jun 28, 2022
1 parent e9cfecc commit 376784e
Show file tree
Hide file tree
Showing 210 changed files with 569 additions and 358 deletions.
3 changes: 2 additions & 1 deletion base/i18n/icu_mergeable_data_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/feature_list.h"
#include "base/files/memory_mapped_file.h"
#include "base/i18n/base_i18n_export.h"
#include "base/memory/raw_ptr.h"

namespace base::i18n {

Expand Down Expand Up @@ -105,7 +106,7 @@ class BASE_I18N_EXPORT IcuMergeableDataFile {

File lacros_file_;
int64_t lacros_length_ = 0;
uint8_t* lacros_data_ = nullptr;
raw_ptr<uint8_t> lacros_data_ = nullptr;
bool used_cached_hashes_ = false;
};

Expand Down
10 changes: 6 additions & 4 deletions chrome/browser/apps/app_service/app_service_proxy_lacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "base/callback.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/apps/app_service/browser_app_launcher.h"
Expand Down Expand Up @@ -299,9 +300,9 @@ class AppServiceProxyLacros : public KeyedService,

// |host_| owns |this|, as the InnerIconLoader is an AppServiceProxyLacros
// field.
AppServiceProxyLacros* host_;
raw_ptr<AppServiceProxyLacros> host_;

apps::IconLoader* overriding_icon_loader_for_testing_ = nullptr;
raw_ptr<apps::IconLoader> overriding_icon_loader_for_testing_ = nullptr;
};

bool IsValidProfile();
Expand Down Expand Up @@ -332,7 +333,7 @@ class AppServiceProxyLacros : public KeyedService,

apps::PreferredAppsList preferred_apps_list_;

Profile* profile_;
raw_ptr<Profile> profile_;

// TODO(crbug.com/1061843): Remove BrowserAppLauncher and merge the interfaces
// to AppServiceProxyLacros when publishers(ExtensionApps and WebApps) can run
Expand All @@ -350,7 +351,8 @@ class AppServiceProxyLacros : public KeyedService,

std::unique_ptr<web_app::LacrosWebAppsController> lacros_web_apps_controller_;
mojo::Receiver<crosapi::mojom::AppServiceSubscriber> crosapi_receiver_{this};
crosapi::mojom::AppServiceProxy* remote_crosapi_app_service_proxy_ = nullptr;
raw_ptr<crosapi::mojom::AppServiceProxy> remote_crosapi_app_service_proxy_ =
nullptr;
int crosapi_app_service_proxy_version_ = 0;

base::WeakPtrFactory<AppServiceProxyLacros> weak_ptr_factory_{this};
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/apps/app_service/app_web_contents_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_APPS_APP_SERVICE_APP_WEB_CONTENTS_DATA_H_
#define CHROME_BROWSER_APPS_APP_SERVICE_APP_WEB_CONTENTS_DATA_H_

#include "base/memory/raw_ptr.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"

Expand Down Expand Up @@ -34,7 +35,7 @@ class AppWebContentsData
// content::WebContentsObserver:
void WebContentsDestroyed() override;

Client* client_;
raw_ptr<Client> client_;
};

} // namespace apps
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/apps/app_service/browser_app_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <string>

#include "base/memory/raw_ptr.h"
#include "base/unguessable_token.h"
#include "build/chromeos_buildflags.h"
#include "components/services/app_service/public/cpp/browser_app_instance_update.h"
Expand Down Expand Up @@ -61,7 +62,7 @@ struct BrowserAppInstance {
// Mutable attributes.
// Window may change for an app tab when a window gets dragged, but stays the
// same for an app window.
aura::Window* window;
raw_ptr<aura::Window> window;
std::string title;
bool is_browser_active;
// If a tab is active in the browser's tab strip. Only applicable to instances
Expand Down Expand Up @@ -94,7 +95,7 @@ struct BrowserWindowInstance {

// Immutable attributes.
const base::UnguessableToken id;
aura::Window* const window;
const raw_ptr<aura::Window> window;
uint32_t browser_session_id;
uint32_t restored_browser_session_id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>

#include "base/containers/contains.h"
#include "base/memory/raw_ptr.h"
#include "base/process/process.h"
#include "base/strings/utf_string_conversions.h"
#include "build/chromeos_buildflags.h"
Expand Down Expand Up @@ -172,7 +173,7 @@ class BrowserAppInstanceTracker::WebContentsObserver
}

private:
BrowserAppInstanceTracker* const owner_;
const raw_ptr<BrowserAppInstanceTracker> owner_;
};

BrowserAppInstanceTracker::BrowserAppInstanceTracker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <set>

#include "base/check.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/scoped_multi_source_observation.h"
#include "base/unguessable_token.h"
Expand Down Expand Up @@ -181,7 +182,7 @@ class BrowserAppInstanceTracker : public TabStripModelObserver,
bool IsBrowserTracked(Browser* browser) const;
bool IsActivationClientTracked(wm::ActivationClient* client) const;

Profile* const profile_;
const raw_ptr<Profile> profile_;

std::map<content::WebContents*, std::unique_ptr<WebContentsObserver>>
webcontents_to_observer_map_;
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/ash/crosapi/crosapi_ash.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <memory>

#include "base/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ash/crosapi/crosapi_id.h"
#include "chromeos/crosapi/mojom/crosapi.mojom.h"
Expand Down Expand Up @@ -488,7 +489,7 @@ class CrosapiAsh : public mojom::Crosapi {

// Only set in the test ash chrome binary. In production ash this is always
// nullptr.
TestControllerReceiver* test_controller_ = nullptr;
raw_ptr<TestControllerReceiver> test_controller_ = nullptr;

mojo::ReceiverSet<mojom::Crosapi, CrosapiId> receiver_set_;
std::map<mojo::ReceiverId, base::OnceClosure> disconnect_handler_map_;
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/ash/file_system_provider/request_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "base/callback.h"
#include "base/files/file.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/time/time.h"
Expand Down Expand Up @@ -183,10 +184,10 @@ class RequestManager {
// and user.
bool IsInteractingWithUser() const;

Profile* profile_; // Not owned.
raw_ptr<Profile> profile_; // Not owned.
std::string provider_id_;
std::map<int, std::unique_ptr<Request>> requests_;
NotificationManagerInterface* notification_manager_; // Not owned.
raw_ptr<NotificationManagerInterface> notification_manager_; // Not owned.
int next_id_;
base::TimeDelta timeout_;
base::ObserverList<Observer>::Unchecked observers_;
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/ash/file_system_provider/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "base/files/file.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/threading/thread_checker.h"
Expand Down Expand Up @@ -201,8 +202,8 @@ class Service : public KeyedService,
// then returns nullptr.
ProviderInterface* GetProvider(const ProviderId& provider_id);

Profile* profile_;
extensions::ExtensionRegistry* extension_registry_; // Not owned.
raw_ptr<Profile> profile_;
raw_ptr<extensions::ExtensionRegistry> extension_registry_; // Not owned.
base::ObserverList<Observer>::Unchecked observers_;
std::map<FileSystemKey, std::unique_ptr<ProvidedFileSystemInterface>>
file_system_map_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>

#include "base/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ash/platform_keys/key_permissions/key_permissions_service.h"
#include "chrome/browser/browser_process.h"
Expand Down Expand Up @@ -87,8 +88,8 @@ class KeyPermissionsServiceImpl : public KeyPermissionsService {

const bool is_regular_user_profile_;
const bool profile_is_managed_;
PlatformKeysService* const platform_keys_service_;
KeyPermissionsManager* const profile_key_permissions_manager_;
const raw_ptr<PlatformKeysService> platform_keys_service_;
const raw_ptr<KeyPermissionsManager> profile_key_permissions_manager_;
base::WeakPtrFactory<KeyPermissionsServiceImpl> weak_factory_{this};
};

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/certificate_manager_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class CertsSourcePolicy : public CertificateManagerModel::CertsSource,
SetCertInfos(std::move(cert_infos));
}

chromeos::PolicyCertificateProvider* policy_certs_provider_;
raw_ptr<chromeos::PolicyCertificateProvider> policy_certs_provider_;
Mode mode_;
};

Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/certificate_manager_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class CertificateManagerModel {
struct Params {
#if BUILDFLAG(IS_CHROMEOS)
// May be nullptr.
chromeos::PolicyCertificateProvider* policy_certs_provider = nullptr;
raw_ptr<chromeos::PolicyCertificateProvider> policy_certs_provider =
nullptr;
// May be nullptr.
std::unique_ptr<chromeos::CertificateProvider>
extension_certificate_provider;
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/certificate_manager_model_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/certificate_manager_model.h"

#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -297,11 +298,11 @@ class FakeExtensionCertificateProvider : public chromeos::CertificateProvider {
}

private:
const net::CertificateList* extension_client_certificates_;
raw_ptr<const net::CertificateList> extension_client_certificates_;

// If *|extensions_hang| is true, the |FakeExtensionCertificateProvider| hangs
// - it never calls the callbacks passed to |GetCertificates|.
const bool* extensions_hang_;
raw_ptr<const bool> extensions_hang_;
};

// Looks up a |CertInfo| in |org_grouping_map| corresponding to |cert|. Returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/containers/flat_set.h"
#include "base/containers/span.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
#include "base/values.h"
Expand Down Expand Up @@ -76,9 +77,9 @@ class DefaultDelegate : public CertificateProviderService::Delegate,
base::flat_set<std::string> GetSubscribedExtensions(
const std::string& event_name);

CertificateProviderService* const service_;
extensions::ExtensionRegistry* const registry_;
extensions::EventRouter* const event_router_;
const raw_ptr<CertificateProviderService> service_;
const raw_ptr<extensions::ExtensionRegistry> registry_;
const raw_ptr<extensions::EventRouter> event_router_;
};

// Constructs the "onCertificatesUpdateRequested" event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/base64.h"
#include "base/bind.h"
#include "base/containers/span.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string_piece.h"
#include "base/test/test_mock_time_task_runner.h"
Expand Down Expand Up @@ -249,7 +250,7 @@ class CertificateProviderServiceTest : public testing::Test {

scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
base::ThreadTaskRunnerHandle task_runner_handle_;
TestDelegate* test_delegate_ = nullptr;
raw_ptr<TestDelegate> test_delegate_ = nullptr;
testing::StrictMock<MockObserver> observer_;
std::unique_ptr<CertificateProvider> certificate_provider_;
std::unique_ptr<CertificateProviderService> service_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <string>

#include "base/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/certificate_provider/security_token_pin_dialog_host.h"

Expand Down Expand Up @@ -56,9 +57,9 @@ class SecurityTokenPinDialogHostPopupImpl final
SecurityTokenPinDialogClosedCallback pin_dialog_closed_callback_;

// Owned by |active_window_|.
RequestPinView* active_pin_dialog_ = nullptr;
raw_ptr<RequestPinView> active_pin_dialog_ = nullptr;
// Owned by the UI code (NativeWidget).
views::Widget* active_window_ = nullptr;
raw_ptr<views::Widget> active_window_ = nullptr;

base::WeakPtrFactory<SecurityTokenPinDialogHostPopupImpl> weak_ptr_factory_{
this};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>

#include "base/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/values.h"
#include "extensions/common/extension_id.h"
Expand Down Expand Up @@ -103,7 +104,7 @@ class TestCertificateProviderExtension final {
const base::Value& pin,
ReplyToJsCallback callback);

content::BrowserContext* const browser_context_;
const raw_ptr<content::BrowserContext> browser_context_;
const scoped_refptr<net::X509Certificate> certificate_;
std::unique_ptr<crypto::RSAPrivateKey> private_key_;
int certificate_request_count_ = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <memory>

#include "base/memory/raw_ptr.h"
#include "chrome/test/base/mixin_based_in_process_browser_test.h"

class ExtensionForceInstallMixin;
Expand Down Expand Up @@ -55,7 +56,7 @@ class TestCertificateProviderExtensionMixin final
}

private:
ExtensionForceInstallMixin* const extension_force_install_mixin_;
const raw_ptr<ExtensionForceInstallMixin> extension_force_install_mixin_;
std::unique_ptr<TestCertificateProviderExtension>
certificate_provider_extension_;
};
Expand Down
7 changes: 4 additions & 3 deletions chrome/browser/chromeos/app_mode/app_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/json/values_util.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
Expand Down Expand Up @@ -295,7 +296,7 @@ class AppSessionMetricsService {
prefs_->CommitPendingWrite(base::DoNothing(), base::DoNothing());
}

PrefService* prefs_;
raw_ptr<PrefService> prefs_;
// Initialized once the kiosk session is started or during recording of the
// previously crashed kiosk session metrics.
// Cleared once the session's duration metric is recorded:
Expand Down Expand Up @@ -340,8 +341,8 @@ class AppSession::AppWindowHandler : public AppWindowRegistry::Observer {
window_registry_->RemoveObserver(this);
}

AppSession* const app_session_;
AppWindowRegistry* window_registry_ = nullptr;
const raw_ptr<AppSession> app_session_;
raw_ptr<AppWindowRegistry> window_registry_ = nullptr;
std::string app_id_;
bool app_window_created_ = false;
};
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/chromeos/app_mode/app_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>

#include "base/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "chrome/browser/chromeos/app_mode/app_session_browser_window_handler.h"
#include "chrome/browser/chromeos/app_mode/kiosk_session_plugin_handler_delegate.h"
Expand Down Expand Up @@ -116,7 +117,7 @@ class AppSession : public KioskSessionPluginHandlerDelegate {
std::unique_ptr<AppSessionBrowserWindowHandler> browser_window_handler_;
std::unique_ptr<KioskSessionPluginHandler> plugin_handler_;

Profile* profile_ = nullptr;
raw_ptr<Profile> profile_ = nullptr;

base::OnceClosure attempt_user_exit_;
const std::unique_ptr<AppSessionMetricsService> metrics_service_;
Expand Down
Loading

0 comments on commit 376784e

Please sign in to comment.