diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 07:01:07 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 07:01:07 +0000 |
commit | 2dea5c03e970b260c0a7c339d734a8347af44fbb (patch) | |
tree | b38a67618091a110b042e42653185fdf637eea4a | |
parent | fbcdc4a860043f2cbc71a3dc52a56308045aa93a (diff) | |
download | chromium_src-2dea5c03e970b260c0a7c339d734a8347af44fbb.zip chromium_src-2dea5c03e970b260c0a7c339d734a8347af44fbb.tar.gz chromium_src-2dea5c03e970b260c0a7c339d734a8347af44fbb.tar.bz2 |
RefCounted types should not have public destructors, chrome/browser/ part 5
BUG=123295
TEST=none
Review URL: http://codereview.chromium.org/10068036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133870 0039d316-1c4b-4281-b951-d872f2087c98
49 files changed, 356 insertions, 277 deletions
diff --git a/chrome/browser/password_manager/mock_password_store.cc b/chrome/browser/password_manager/mock_password_store.cc index 087ad83..ad7f753 100644 --- a/chrome/browser/password_manager/mock_password_store.cc +++ b/chrome/browser/password_manager/mock_password_store.cc @@ -6,8 +6,6 @@ MockPasswordStore::MockPasswordStore() {} -MockPasswordStore::~MockPasswordStore() {} - // static scoped_refptr<RefcountedProfileKeyedService> MockPasswordStore::Build( Profile* profile) { @@ -15,3 +13,5 @@ scoped_refptr<RefcountedProfileKeyedService> MockPasswordStore::Build( } void MockPasswordStore::ShutdownOnUIThread() {} + +MockPasswordStore::~MockPasswordStore() {} diff --git a/chrome/browser/password_manager/mock_password_store.h b/chrome/browser/password_manager/mock_password_store.h index 5a13964..627b5db 100644 --- a/chrome/browser/password_manager/mock_password_store.h +++ b/chrome/browser/password_manager/mock_password_store.h @@ -14,7 +14,6 @@ class Profile; class MockPasswordStore : public PasswordStore { public: MockPasswordStore(); - virtual ~MockPasswordStore(); static scoped_refptr<RefcountedProfileKeyedService> Build(Profile* profile); @@ -40,6 +39,9 @@ class MockPasswordStore : public PasswordStore { bool(std::vector<webkit::forms::PasswordForm*>*)); virtual void ShutdownOnUIThread(); + + private: + virtual ~MockPasswordStore(); }; #endif // CHROME_BROWSER_PASSWORD_MANAGER_MOCK_PASSWORD_STORE_H_ diff --git a/chrome/browser/password_manager/password_manager.h b/chrome/browser/password_manager/password_manager.h index 86dba4e..c3f86ac 100644 --- a/chrome/browser/password_manager/password_manager.h +++ b/chrome/browser/password_manager/password_manager.h @@ -35,6 +35,7 @@ class PasswordManager : public LoginModel, // The delegate passed in is required to outlive the PasswordManager. PasswordManager(content::WebContents* web_contents, PasswordManagerDelegate* delegate); + virtual ~PasswordManager(); // Is password autofill enabled for the current profile? diff --git a/chrome/browser/password_manager/password_store.h b/chrome/browser/password_manager/password_store.h index acb4a31..eaab997 100644 --- a/chrome/browser/password_manager/password_store.h +++ b/chrome/browser/password_manager/password_store.h @@ -62,6 +62,8 @@ class PasswordStore std::vector<webkit::forms::PasswordForm*> > { public: explicit GetLoginsRequest(const GetLoginsCallback& callback); + + protected: virtual ~GetLoginsRequest(); private: diff --git a/chrome/browser/password_manager/password_store_win.cc b/chrome/browser/password_manager/password_store_win.cc index 6a4cbf7..faea2d3 100644 --- a/chrome/browser/password_manager/password_store_win.cc +++ b/chrome/browser/password_manager/password_store_win.cc @@ -39,6 +39,9 @@ class FormGetLoginsRequest : public PasswordStore::GetLoginsRequest { } bool IsLoginsRequest() const { return !!form_.get(); } + protected: + virtual ~FormGetLoginsRequest() {} + private: scoped_ptr<PasswordForm> form_; }; diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc index 00d7c9d..f18d6c5 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.cc +++ b/chrome/browser/policy/configuration_policy_pref_store.cc @@ -48,10 +48,6 @@ ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( policy_service_->AddObserver(POLICY_DOMAIN_CHROME, "", this); } -ConfigurationPolicyPrefStore::~ConfigurationPolicyPrefStore() { - policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, "", this); -} - void ConfigurationPolicyPrefStore::AddObserver(PrefStore::Observer* observer) { observers_.AddObserver(observer); } @@ -110,6 +106,10 @@ ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore() { POLICY_LEVEL_RECOMMENDED); } +ConfigurationPolicyPrefStore::~ConfigurationPolicyPrefStore() { + policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, "", this); +} + void ConfigurationPolicyPrefStore::Refresh() { scoped_ptr<PrefValueMap> new_prefs(CreatePreferencesFromPolicies()); std::vector<std::string> changed_prefs; diff --git a/chrome/browser/policy/configuration_policy_pref_store.h b/chrome/browser/policy/configuration_policy_pref_store.h index bbd13be..f3d33a4 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.h +++ b/chrome/browser/policy/configuration_policy_pref_store.h @@ -30,7 +30,6 @@ class ConfigurationPolicyPrefStore // Does not take ownership of |service|. Only policies of the given |level| // will be mapped. ConfigurationPolicyPrefStore(PolicyService* service, PolicyLevel level); - virtual ~ConfigurationPolicyPrefStore(); // PrefStore methods: virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; @@ -56,6 +55,8 @@ class ConfigurationPolicyPrefStore static ConfigurationPolicyPrefStore* CreateRecommendedPolicyPrefStore(); private: + virtual ~ConfigurationPolicyPrefStore(); + // Refreshes policy information, rereading policy from the policy service and // sending out change notifications as appropriate. void Refresh(); diff --git a/chrome/browser/policy/device_management_service.cc b/chrome/browser/policy/device_management_service.cc index 90411bb..aab92e1 100644 --- a/chrome/browser/policy/device_management_service.cc +++ b/chrome/browser/policy/device_management_service.cc @@ -186,9 +186,10 @@ const std::string& GetPlatformString() { class DeviceManagementRequestContext : public net::URLRequestContext { public: explicit DeviceManagementRequestContext(net::URLRequestContext* base_context); - virtual ~DeviceManagementRequestContext(); private: + virtual ~DeviceManagementRequestContext(); + // Overridden from net::URLRequestContext: virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; }; diff --git a/chrome/browser/policy/file_based_policy_loader.cc b/chrome/browser/policy/file_based_policy_loader.cc index 6ceea3e..763cb99 100644 --- a/chrome/browser/policy/file_based_policy_loader.cc +++ b/chrome/browser/policy/file_based_policy_loader.cc @@ -42,7 +42,6 @@ class FileBasedPolicyWatcherDelegate : public FilePathWatcher::Delegate { explicit FileBasedPolicyWatcherDelegate( scoped_refptr<FileBasedPolicyLoader> loader) : loader_(loader) {} - virtual ~FileBasedPolicyWatcherDelegate() {} // FilePathWatcher::Delegate implementation: virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { @@ -54,6 +53,8 @@ class FileBasedPolicyWatcherDelegate : public FilePathWatcher::Delegate { } private: + virtual ~FileBasedPolicyWatcherDelegate() {} + scoped_refptr<FileBasedPolicyLoader> loader_; DISALLOW_COPY_AND_ASSIGN(FileBasedPolicyWatcherDelegate); }; diff --git a/chrome/browser/prefs/command_line_pref_store.cc b/chrome/browser/prefs/command_line_pref_store.cc index ba83704..1547b1b 100644 --- a/chrome/browser/prefs/command_line_pref_store.cc +++ b/chrome/browser/prefs/command_line_pref_store.cc @@ -81,6 +81,19 @@ CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) CommandLinePrefStore::~CommandLinePrefStore() {} +bool CommandLinePrefStore::ValidateProxySwitches() { + if (command_line_->HasSwitch(switches::kNoProxyServer) && + (command_line_->HasSwitch(switches::kProxyAutoDetect) || + command_line_->HasSwitch(switches::kProxyServer) || + command_line_->HasSwitch(switches::kProxyPacUrl) || + command_line_->HasSwitch(switches::kProxyBypassList))) { + LOG(WARNING) << "Additional command-line proxy switches specified when --" + << switches::kNoProxyServer << " was also specified."; + return false; + } + return true; +} + void CommandLinePrefStore::ApplySimpleSwitches() { // Look for each switch we know about and set its preference accordingly. for (size_t i = 0; i < arraysize(string_switch_map_); ++i) { @@ -116,19 +129,6 @@ void CommandLinePrefStore::ApplySimpleSwitches() { } } -bool CommandLinePrefStore::ValidateProxySwitches() { - if (command_line_->HasSwitch(switches::kNoProxyServer) && - (command_line_->HasSwitch(switches::kProxyAutoDetect) || - command_line_->HasSwitch(switches::kProxyServer) || - command_line_->HasSwitch(switches::kProxyPacUrl) || - command_line_->HasSwitch(switches::kProxyBypassList))) { - LOG(WARNING) << "Additional command-line proxy switches specified when --" - << switches::kNoProxyServer << " was also specified."; - return false; - } - return true; -} - void CommandLinePrefStore::ApplyProxyMode() { if (command_line_->HasSwitch(switches::kNoProxyServer)) { SetValue(prefs::kProxy, diff --git a/chrome/browser/prefs/command_line_pref_store.h b/chrome/browser/prefs/command_line_pref_store.h index 373490d..6ac8a16 100644 --- a/chrome/browser/prefs/command_line_pref_store.h +++ b/chrome/browser/prefs/command_line_pref_store.h @@ -17,14 +17,17 @@ class CommandLinePrefStore : public ValueMapPrefStore { public: explicit CommandLinePrefStore(const CommandLine* command_line); - virtual ~CommandLinePrefStore(); protected: + virtual ~CommandLinePrefStore(); + // Logs a message and returns false if the proxy switches are // self-contradictory. Protected so it can be used in unit testing. bool ValidateProxySwitches(); private: + friend class TestCommandLinePrefStore; + struct StringSwitchToPreferenceMapEntry { const char* switch_name; const char* preference_path; diff --git a/chrome/browser/prefs/command_line_pref_store_unittest.cc b/chrome/browser/prefs/command_line_pref_store_unittest.cc index ecb81d2..bc1edb9 100644 --- a/chrome/browser/prefs/command_line_pref_store_unittest.cc +++ b/chrome/browser/prefs/command_line_pref_store_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,6 +16,11 @@ namespace { +const char unknown_bool[] = "unknown_switch"; +const char unknown_string[] = "unknown_other_switch"; + +} // namespace + class TestCommandLinePrefStore : public CommandLinePrefStore { public: explicit TestCommandLinePrefStore(CommandLine* cl) @@ -51,12 +56,10 @@ class TestCommandLinePrefStore : public CommandLinePrefStore { EXPECT_EQ(*ciphers, cipher_string); } } -}; -const char unknown_bool[] = "unknown_switch"; -const char unknown_string[] = "unknown_other_switch"; - -} // namespace + private: + virtual ~TestCommandLinePrefStore() {} +}; // Tests a simple string pref on the command line. TEST(CommandLinePrefStoreTest, SimpleStringPref) { diff --git a/chrome/browser/prefs/default_pref_store.cc b/chrome/browser/prefs/default_pref_store.cc index 06168bc..3e084d7 100644 --- a/chrome/browser/prefs/default_pref_store.cc +++ b/chrome/browser/prefs/default_pref_store.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,8 +8,6 @@ using base::Value; DefaultPrefStore::DefaultPrefStore() {} -DefaultPrefStore::~DefaultPrefStore() {} - void DefaultPrefStore::SetDefaultValue(const std::string& key, Value* value) { CHECK(GetValue(key, NULL) == READ_NO_VALUE); SetValue(key, value); @@ -24,3 +22,5 @@ base::Value::Type DefaultPrefStore::GetType(const std::string& key) const { const Value* value; return GetValue(key, &value) == READ_OK ? value->GetType() : Value::TYPE_NULL; } + +DefaultPrefStore::~DefaultPrefStore() {} diff --git a/chrome/browser/prefs/default_pref_store.h b/chrome/browser/prefs/default_pref_store.h index 96de6d3..c3d33e2 100644 --- a/chrome/browser/prefs/default_pref_store.h +++ b/chrome/browser/prefs/default_pref_store.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,7 +16,6 @@ class DefaultPrefStore : public ValueMapPrefStore { public: DefaultPrefStore(); - virtual ~DefaultPrefStore(); // Stores a new |value| for |key|. Assumes ownership of |value|. void SetDefaultValue(const std::string& key, Value* value); @@ -28,6 +27,9 @@ class DefaultPrefStore : public ValueMapPrefStore { // has not been registered. base::Value::Type GetType(const std::string& key) const; + protected: + virtual ~DefaultPrefStore(); + private: DISALLOW_COPY_AND_ASSIGN(DefaultPrefStore); }; diff --git a/chrome/browser/prefs/overlay_user_pref_store.cc b/chrome/browser/prefs/overlay_user_pref_store.cc index 8d04ec3..b91af63 100644 --- a/chrome/browser/prefs/overlay_user_pref_store.cc +++ b/chrome/browser/prefs/overlay_user_pref_store.cc @@ -13,10 +13,6 @@ OverlayUserPrefStore::OverlayUserPrefStore( underlay_->AddObserver(this); } -OverlayUserPrefStore::~OverlayUserPrefStore() { - underlay_->RemoveObserver(this); -} - bool OverlayUserPrefStore::IsSetInOverlay(const std::string& key) const { return overlay_.GetValue(key, NULL); } @@ -136,6 +132,16 @@ void OverlayUserPrefStore::ReportValueChanged(const std::string& key) { FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); } +void OverlayUserPrefStore::OnPrefValueChanged(const std::string& key) { + if (!overlay_.GetValue(GetOverlayKey(key), NULL)) + ReportValueChanged(GetOverlayKey(key)); +} + +void OverlayUserPrefStore::OnInitializationCompleted(bool succeeded) { + FOR_EACH_OBSERVER(PrefStore::Observer, observers_, + OnInitializationCompleted(succeeded)); +} + void OverlayUserPrefStore::RegisterOverlayPref(const std::string& key) { RegisterOverlayPref(key, key); } @@ -155,14 +161,8 @@ void OverlayUserPrefStore::RegisterOverlayPref( underlay_to_overlay_names_map_[underlay_key] = overlay_key; } -void OverlayUserPrefStore::OnPrefValueChanged(const std::string& key) { - if (!overlay_.GetValue(GetOverlayKey(key), NULL)) - ReportValueChanged(GetOverlayKey(key)); -} - -void OverlayUserPrefStore::OnInitializationCompleted(bool succeeded) { - FOR_EACH_OBSERVER(PrefStore::Observer, observers_, - OnInitializationCompleted(succeeded)); +OverlayUserPrefStore::~OverlayUserPrefStore() { + underlay_->RemoveObserver(this); } const std::string& OverlayUserPrefStore::GetOverlayKey( diff --git a/chrome/browser/prefs/overlay_user_pref_store.h b/chrome/browser/prefs/overlay_user_pref_store.h index 105dc67..0dcc387 100644 --- a/chrome/browser/prefs/overlay_user_pref_store.h +++ b/chrome/browser/prefs/overlay_user_pref_store.h @@ -23,7 +23,6 @@ class OverlayUserPrefStore : public PersistentPrefStore, public PrefStore::Observer { public: explicit OverlayUserPrefStore(PersistentPrefStore* underlay); - virtual ~OverlayUserPrefStore(); // Returns true if a value has been set for the |key| in this // OverlayUserPrefStore, i.e. if it potentially overrides a value @@ -53,17 +52,20 @@ class OverlayUserPrefStore : public PersistentPrefStore, virtual void CommitPendingWrite() OVERRIDE; virtual void ReportValueChanged(const std::string& key) OVERRIDE; + // Methods of PrefStore::Observer. + virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; + virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; + void RegisterOverlayPref(const std::string& key); void RegisterOverlayPref(const std::string& overlay_key, const std::string& underlay_key); + protected: + virtual ~OverlayUserPrefStore(); + private: typedef std::map<std::string, std::string> NamesMap; - // Methods of PrefStore::Observer. - virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; - virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; - const std::string& GetOverlayKey(const std::string& underlay_key) const; const std::string& GetUnderlayKey(const std::string& overlay_key) const; diff --git a/chrome/browser/prefs/testing_pref_store.cc b/chrome/browser/prefs/testing_pref_store.cc index f7ce0f4..4fe53f8 100644 --- a/chrome/browser/prefs/testing_pref_store.cc +++ b/chrome/browser/prefs/testing_pref_store.cc @@ -9,9 +9,8 @@ TestingPrefStore::TestingPrefStore() : read_only_(true), prefs_written_(false), - init_complete_(false) {} - -TestingPrefStore::~TestingPrefStore() {} + init_complete_(false) { +} PrefStore::ReadResult TestingPrefStore::GetValue(const std::string& key, const Value** value) const { @@ -134,3 +133,5 @@ bool TestingPrefStore::GetBoolean(const std::string& key, bool* value) const { void TestingPrefStore::set_read_only(bool read_only) { read_only_ = read_only; } + +TestingPrefStore::~TestingPrefStore() {} diff --git a/chrome/browser/prefs/testing_pref_store.h b/chrome/browser/prefs/testing_pref_store.h index 9cda821..f7e2623 100644 --- a/chrome/browser/prefs/testing_pref_store.h +++ b/chrome/browser/prefs/testing_pref_store.h @@ -20,7 +20,6 @@ class TestingPrefStore : public PersistentPrefStore { public: TestingPrefStore(); - virtual ~TestingPrefStore(); // Overriden from PrefStore. virtual ReadResult GetValue(const std::string& key, @@ -65,6 +64,9 @@ class TestingPrefStore : public PersistentPrefStore { // |TestingPrefStore|. virtual void set_read_only(bool read_only); + protected: + virtual ~TestingPrefStore(); + private: // Stores the preference values. PrefValueMap prefs_; diff --git a/chrome/browser/prefs/value_map_pref_store.cc b/chrome/browser/prefs/value_map_pref_store.cc index 6bb1dec..98f9cdd 100644 --- a/chrome/browser/prefs/value_map_pref_store.cc +++ b/chrome/browser/prefs/value_map_pref_store.cc @@ -11,8 +11,6 @@ ValueMapPrefStore::ValueMapPrefStore() {} -ValueMapPrefStore::~ValueMapPrefStore() {} - PrefStore::ReadResult ValueMapPrefStore::GetValue(const std::string& key, const Value** value) const { return prefs_.GetValue(key, value) ? READ_OK : READ_NO_VALUE; @@ -30,20 +28,6 @@ size_t ValueMapPrefStore::NumberOfObservers() const { return observers_.size(); } -void ValueMapPrefStore::SetValue(const std::string& key, Value* value) { - if (prefs_.SetValue(key, value)) - FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); -} - -void ValueMapPrefStore::RemoveValue(const std::string& key) { - if (prefs_.RemoveValue(key)) - FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); -} - -void ValueMapPrefStore::NotifyInitializationCompleted() { - FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true)); -} - ValueMapPrefStore::iterator ValueMapPrefStore::begin() { return prefs_.begin(); } @@ -59,3 +43,19 @@ ValueMapPrefStore::const_iterator ValueMapPrefStore::begin() const { ValueMapPrefStore::const_iterator ValueMapPrefStore::end() const { return prefs_.end(); } + +ValueMapPrefStore::~ValueMapPrefStore() {} + +void ValueMapPrefStore::SetValue(const std::string& key, Value* value) { + if (prefs_.SetValue(key, value)) + FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); +} + +void ValueMapPrefStore::RemoveValue(const std::string& key) { + if (prefs_.RemoveValue(key)) + FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); +} + +void ValueMapPrefStore::NotifyInitializationCompleted() { + FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true)); +} diff --git a/chrome/browser/prefs/value_map_pref_store.h b/chrome/browser/prefs/value_map_pref_store.h index b440ba1..011a370 100644 --- a/chrome/browser/prefs/value_map_pref_store.h +++ b/chrome/browser/prefs/value_map_pref_store.h @@ -22,7 +22,6 @@ class ValueMapPrefStore : public PrefStore { typedef std::map<std::string, base::Value*>::const_iterator const_iterator; ValueMapPrefStore(); - virtual ~ValueMapPrefStore(); // PrefStore overrides: virtual ReadResult GetValue(const std::string& key, @@ -37,6 +36,8 @@ class ValueMapPrefStore : public PrefStore { const_iterator end() const; protected: + virtual ~ValueMapPrefStore(); + // Store a |value| for |key| in the store. Also generates an notification if // the value changed. Assumes ownership of |value|, which must be non-NULL. void SetValue(const std::string& key, base::Value* value); diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc index 824afd5..47f9a19 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc @@ -37,19 +37,26 @@ class CloudPrintProxyService::TokenExpiredNotificationDelegate CloudPrintProxyService* cloud_print_service) : cloud_print_service_(cloud_print_service) { } + void Display() {} + void Error() { cloud_print_service_->OnTokenExpiredNotificationError(); } + void Close(bool by_user) { cloud_print_service_->OnTokenExpiredNotificationClosed(by_user); } + void Click() { cloud_print_service_->OnTokenExpiredNotificationClick(); } + std::string id() const { return "cloudprint.tokenexpired"; } private: + virtual ~TokenExpiredNotificationDelegate() {} + CloudPrintProxyService* cloud_print_service_; DISALLOW_COPY_AND_ASSIGN(TokenExpiredNotificationDelegate); }; diff --git a/chrome/browser/printing/cloud_print/virtual_driver_install_helper.h b/chrome/browser/printing/cloud_print/virtual_driver_install_helper.h index ff5c845..ab4af53 100644 --- a/chrome/browser/printing/cloud_print/virtual_driver_install_helper.h +++ b/chrome/browser/printing/cloud_print/virtual_driver_install_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,6 +24,10 @@ class VirtualDriverInstallHelper static void SetUpUninstall(); private: + friend class base::RefCountedThreadSafe<VirtualDriverInstallHelper>; + + ~VirtualDriverInstallHelper() {} + void InstallVirtualDriverTask(); void UninstallVirtualDriverTask(); }; diff --git a/chrome/browser/printing/print_job_unittest.cc b/chrome/browser/printing/print_job_unittest.cc index 59b79e2..73b57e0 100644 --- a/chrome/browser/printing/print_job_unittest.cc +++ b/chrome/browser/printing/print_job_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -57,6 +57,8 @@ class TestOwner : public printing::PrintJobWorkerOwner { } private: + virtual ~TestOwner() {} + printing::PrintSettings settings_; }; diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc index 763320b..7f2efba 100644 --- a/chrome/browser/printing/print_preview_tab_controller.cc +++ b/chrome/browser/printing/print_preview_tab_controller.cc @@ -198,8 +198,6 @@ PrintPreviewTabController::PrintPreviewTabController() is_creating_print_preview_tab_(false) { } -PrintPreviewTabController::~PrintPreviewTabController() {} - // static PrintPreviewTabController* PrintPreviewTabController::GetInstance() { if (!g_browser_process) @@ -251,6 +249,14 @@ TabContentsWrapper* PrintPreviewTabController::GetPrintPreviewForTab( return NULL; } +TabContentsWrapper* PrintPreviewTabController::GetInitiatorTab( + TabContentsWrapper* preview_tab) { + PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); + if (it != preview_tab_map_.end()) + return preview_tab_map_[preview_tab]; + return NULL; +} + void PrintPreviewTabController::Observe( int type, const content::NotificationSource& source, @@ -286,6 +292,33 @@ void PrintPreviewTabController::Observe( } } +// static +bool PrintPreviewTabController::IsPrintPreviewTab(TabContentsWrapper* tab) { + return IsPrintPreviewURL(tab->web_contents()->GetURL()); +} + +// static +bool PrintPreviewTabController::IsPrintPreviewURL(const GURL& url) { + return (url.SchemeIs(chrome::kChromeUIScheme) && + url.host() == chrome::kChromeUIPrintHost); +} + +void PrintPreviewTabController::EraseInitiatorTabInfo( + TabContentsWrapper* preview_tab) { + PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); + if (it == preview_tab_map_.end()) + return; + + RemoveObservers(it->second); + preview_tab_map_[preview_tab] = NULL; +} + +bool PrintPreviewTabController::is_creating_print_preview_tab() const { + return is_creating_print_preview_tab_; +} + +PrintPreviewTabController::~PrintPreviewTabController() {} + void PrintPreviewTabController::OnRendererProcessClosed( content::RenderProcessHost* rph) { // Store tabs in a vector and deal with them after iterating through @@ -371,39 +404,6 @@ void PrintPreviewTabController::OnNavEntryCommitted( RemoveInitiatorTab(tab, true); } -// static -bool PrintPreviewTabController::IsPrintPreviewTab(TabContentsWrapper* tab) { - return IsPrintPreviewURL(tab->web_contents()->GetURL()); -} - -// static -bool PrintPreviewTabController::IsPrintPreviewURL(const GURL& url) { - return (url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUIPrintHost); -} - -void PrintPreviewTabController::EraseInitiatorTabInfo( - TabContentsWrapper* preview_tab) { - PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); - if (it == preview_tab_map_.end()) - return; - - RemoveObservers(it->second); - preview_tab_map_[preview_tab] = NULL; -} - -bool PrintPreviewTabController::is_creating_print_preview_tab() const { - return is_creating_print_preview_tab_; -} - -TabContentsWrapper* PrintPreviewTabController::GetInitiatorTab( - TabContentsWrapper* preview_tab) { - PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); - if (it != preview_tab_map_.end()) - return preview_tab_map_[preview_tab]; - return NULL; -} - TabContentsWrapper* PrintPreviewTabController::CreatePrintPreviewTab( TabContentsWrapper* initiator_tab) { AutoReset<bool> auto_reset(&is_creating_print_preview_tab_, true); diff --git a/chrome/browser/printing/print_preview_tab_controller.h b/chrome/browser/printing/print_preview_tab_controller.h index af23ca7..501fc44 100644 --- a/chrome/browser/printing/print_preview_tab_controller.h +++ b/chrome/browser/printing/print_preview_tab_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,8 +36,6 @@ class PrintPreviewTabController public: PrintPreviewTabController(); - virtual ~PrintPreviewTabController(); - static PrintPreviewTabController* GetInstance(); // Initiate print preview for |initiator_tab|. @@ -81,6 +79,8 @@ class PrintPreviewTabController // Value: Initiator tab. typedef std::map<TabContentsWrapper*, TabContentsWrapper*> PrintPreviewTabMap; + virtual ~PrintPreviewTabController(); + // Handler for the RENDERER_PROCESS_CLOSED notification. This is observed when // the initiator renderer crashed. void OnRendererProcessClosed(content::RenderProcessHost* rph); diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index f41e6ca..3840125 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -231,7 +231,6 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { } ProfileIOData::AppRequestContext::AppRequestContext() {} -ProfileIOData::AppRequestContext::~AppRequestContext() {} void ProfileIOData::AppRequestContext::SetCookieStore( net::CookieStore* cookie_store) { @@ -245,6 +244,8 @@ void ProfileIOData::AppRequestContext::SetHttpTransactionFactory( set_http_transaction_factory(http_factory); } +ProfileIOData::AppRequestContext::~AppRequestContext() {} + ProfileIOData::ProfileParams::ProfileParams() : is_incognito(false), clear_local_state_on_exit(false), @@ -252,7 +253,9 @@ ProfileIOData::ProfileParams::ProfileParams() #if defined(ENABLE_NOTIFICATIONS) notification_service(NULL), #endif - profile(NULL) {} + profile(NULL) { +} + ProfileIOData::ProfileParams::~ProfileParams() {} ProfileIOData::ProfileIOData(bool is_incognito) diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index e1c0e2d..2f892ed 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -118,12 +118,13 @@ class ProfileIOData { class AppRequestContext : public ChromeURLRequestContext { public: AppRequestContext(); - virtual ~AppRequestContext(); void SetCookieStore(net::CookieStore* cookie_store); void SetHttpTransactionFactory(net::HttpTransactionFactory* http_factory); private: + virtual ~AppRequestContext(); + scoped_refptr<net::CookieStore> cookie_store_; scoped_ptr<net::HttpTransactionFactory> http_factory_; }; diff --git a/chrome/browser/profiles/refcounted_profile_keyed_service.h b/chrome/browser/profiles/refcounted_profile_keyed_service.h index 0db4351..a7c41af 100644 --- a/chrome/browser/profiles/refcounted_profile_keyed_service.h +++ b/chrome/browser/profiles/refcounted_profile_keyed_service.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_PROFILES_REFCOUNTED_PROFILE_KEYED_SERVICE_H_ #include "base/memory/ref_counted.h" +#include "base/sequenced_task_runner_helpers.h" #include "content/public/browser/browser_thread.h" class RefcountedProfileKeyedService; @@ -42,10 +43,6 @@ class RefcountedProfileKeyedService // the UI thread; you do not need to check for that yourself. virtual void ShutdownOnUIThread() = 0; - // The second pass destruction can happen anywhere unless you specify which - // thread this service must be destroyed on by using the second constructor. - virtual ~RefcountedProfileKeyedService(); - protected: // If your service does not need to be deleted on a specific thread, use the // default constructor. @@ -57,8 +54,13 @@ class RefcountedProfileKeyedService explicit RefcountedProfileKeyedService( const content::BrowserThread::ID thread_id); + // The second pass destruction can happen anywhere unless you specify which + // thread this service must be destroyed on by using the second constructor. + virtual ~RefcountedProfileKeyedService(); + private: friend struct impl::RefcountedProfileKeyedServiceTraits; + friend class base::DeleteHelper<RefcountedProfileKeyedService>; // Do we have to delete this object on a specific thread? bool requires_destruction_on_thread_; diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc index 1d68a4d..b39b63b 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc +++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc @@ -101,7 +101,6 @@ class MockClientSideDetectionService : public ClientSideDetectionService { class MockSafeBrowsingService : public SafeBrowsingService { public: MockSafeBrowsingService() {} - virtual ~MockSafeBrowsingService() {} MOCK_METHOD1(DoDisplayBlockingPage, void(const UnsafeResource& resource)); MOCK_METHOD1(MatchCsdWhitelistUrl, bool(const GURL&)); @@ -117,6 +116,9 @@ class MockSafeBrowsingService : public SafeBrowsingService { callback.Run(false); } + protected: + virtual ~MockSafeBrowsingService() {} + private: DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingService); }; diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc index 75708bb..c67ae59 100644 --- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc +++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc @@ -46,13 +46,15 @@ namespace { class MockSafeBrowsingService : public SafeBrowsingService { public: MockSafeBrowsingService() {} - virtual ~MockSafeBrowsingService() {} MOCK_METHOD1(MatchDownloadWhitelistUrl, bool(const GURL&)); MOCK_METHOD1(MatchDownloadWhitelistString, bool(const std::string&)); MOCK_METHOD2(CheckDownloadUrl, bool(const std::vector<GURL>& url_chain, Client* client)); + protected: + virtual ~MockSafeBrowsingService() {} + private: DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingService); }; @@ -60,10 +62,12 @@ class MockSafeBrowsingService : public SafeBrowsingService { class MockSignatureUtil : public SignatureUtil { public: MockSignatureUtil() {} - virtual ~MockSignatureUtil() {} MOCK_METHOD2(CheckSignature, void(const FilePath&, ClientDownloadRequest_SignatureInfo*)); + protected: + virtual ~MockSignatureUtil() {} + private: DISALLOW_COPY_AND_ASSIGN(MockSignatureUtil); }; diff --git a/chrome/browser/safe_browsing/malware_details_cache.cc b/chrome/browser/safe_browsing/malware_details_cache.cc index 25961ad..43b2b86 100644 --- a/chrome/browser/safe_browsing/malware_details_cache.cc +++ b/chrome/browser/safe_browsing/malware_details_cache.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -37,9 +37,6 @@ MalwareDetailsCacheCollector::MalwareDetailsCacheCollector() current_fetch_(NULL) { } -MalwareDetailsCacheCollector::~MalwareDetailsCacheCollector() { -} - void MalwareDetailsCacheCollector::StartCacheCollection( net::URLRequestContextGetter* request_context_getter, safe_browsing::ResourceMap* resources, @@ -67,6 +64,8 @@ bool MalwareDetailsCacheCollector::HasStarted() { return has_started_; } +MalwareDetailsCacheCollector::~MalwareDetailsCacheCollector() {} + // Fetch a URL and advance to the next one when done. void MalwareDetailsCacheCollector::OpenEntry() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); diff --git a/chrome/browser/safe_browsing/malware_details_cache.h b/chrome/browser/safe_browsing/malware_details_cache.h index 383e8b6..7bf8f9c 100644 --- a/chrome/browser/safe_browsing/malware_details_cache.h +++ b/chrome/browser/safe_browsing/malware_details_cache.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -38,7 +38,6 @@ class MalwareDetailsCacheCollector public: MalwareDetailsCacheCollector(); - virtual ~MalwareDetailsCacheCollector(); // We use |request_context_getter|, we modify |resources| and // |result|, and we call |callback|, so they must all remain alive @@ -58,6 +57,10 @@ class MalwareDetailsCacheCollector virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; private: + friend class base::RefCountedThreadSafe<MalwareDetailsCacheCollector>; + + virtual ~MalwareDetailsCacheCollector(); + // Points to the url for which we are fetching the HTTP cache entry or // redirect chain. safe_browsing::ResourceMap::iterator resources_it_; diff --git a/chrome/browser/safe_browsing/malware_details_history.cc b/chrome/browser/safe_browsing/malware_details_history.cc index 3947f36..1cf11ef 100644 --- a/chrome/browser/safe_browsing/malware_details_history.cc +++ b/chrome/browser/safe_browsing/malware_details_history.cc @@ -30,9 +30,6 @@ MalwareDetailsRedirectsCollector::MalwareDetailsRedirectsCollector( } } -MalwareDetailsRedirectsCollector::~MalwareDetailsRedirectsCollector() { -} - void MalwareDetailsRedirectsCollector::StartHistoryCollection( const std::vector<GURL>& urls, const base::Closure& callback) { @@ -51,6 +48,27 @@ void MalwareDetailsRedirectsCollector::StartHistoryCollection( this, urls)); } +bool MalwareDetailsRedirectsCollector::HasStarted() const { + return has_started_; +} + +const std::vector<safe_browsing::RedirectChain>& +MalwareDetailsRedirectsCollector::GetCollectedUrls() const { + return redirects_urls_; +} + +void MalwareDetailsRedirectsCollector::Observe( + int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_DESTROYED); + DVLOG(1) << "Profile gone."; + profile_ = NULL; +} + +MalwareDetailsRedirectsCollector::~MalwareDetailsRedirectsCollector() {} + void MalwareDetailsRedirectsCollector::StartGetRedirects( const std::vector<GURL>& urls) { // History access from profile needs to happen in UI thread @@ -109,27 +127,8 @@ void MalwareDetailsRedirectsCollector::OnGotQueryRedirectsTo( GetRedirects(*urls_it_); } -bool MalwareDetailsRedirectsCollector::HasStarted() const { - return has_started_; -} - void MalwareDetailsRedirectsCollector::AllDone() { DVLOG(1) << "AllDone"; BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); callback_.Reset(); } - -const std::vector<safe_browsing::RedirectChain>& -MalwareDetailsRedirectsCollector::GetCollectedUrls() const { - return redirects_urls_; -} - -void MalwareDetailsRedirectsCollector::Observe( - int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK_EQ(type, chrome::NOTIFICATION_PROFILE_DESTROYED); - DVLOG(1) << "Profile gone."; - profile_ = NULL; -} diff --git a/chrome/browser/safe_browsing/malware_details_history.h b/chrome/browser/safe_browsing/malware_details_history.h index b956aed..0b9df87 100644 --- a/chrome/browser/safe_browsing/malware_details_history.h +++ b/chrome/browser/safe_browsing/malware_details_history.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,7 +33,6 @@ class MalwareDetailsRedirectsCollector public content::NotificationObserver { public: explicit MalwareDetailsRedirectsCollector(Profile* profile); - virtual ~MalwareDetailsRedirectsCollector(); // Collects urls' redirects chain information from the history service. // We get access to history service via tab_contents in UI thread. @@ -47,11 +46,29 @@ class MalwareDetailsRedirectsCollector // Returns the redirect urls we get from history service const std::vector<safe_browsing::RedirectChain>& GetCollectedUrls() const; + // content::NotificationObserver + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + private: friend struct content::BrowserThread::DeleteOnThread< content::BrowserThread::UI>; friend class base::DeleteHelper<MalwareDetailsRedirectsCollector>; + virtual ~MalwareDetailsRedirectsCollector(); + + void StartGetRedirects(const std::vector<GURL>& urls); + void GetRedirects(const GURL& url); + void OnGotQueryRedirectsTo(HistoryService::Handle handle, + GURL url, + bool success, + history::RedirectList* redirect_list); + + // Posts the callback method back to IO thread when redirects collecting + // is all done. + void AllDone(); + Profile* profile_; CancelableRequestConsumer request_consumer_; @@ -71,21 +88,6 @@ class MalwareDetailsRedirectsCollector content::NotificationRegistrar registrar_; - void StartGetRedirects(const std::vector<GURL>& urls); - void GetRedirects(const GURL& url); - void OnGotQueryRedirectsTo(HistoryService::Handle handle, - GURL url, - bool success, - history::RedirectList* redirect_list); - - // Posts the callback method back to IO thread when redirects collecting - // is all done. - void AllDone(); - - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - DISALLOW_COPY_AND_ASSIGN(MalwareDetailsRedirectsCollector); }; diff --git a/chrome/browser/safe_browsing/malware_details_unittest.cc b/chrome/browser/safe_browsing/malware_details_unittest.cc index 4e3593e..f7821af 100644 --- a/chrome/browser/safe_browsing/malware_details_unittest.cc +++ b/chrome/browser/safe_browsing/malware_details_unittest.cc @@ -138,13 +138,13 @@ class MalwareDetailsWrap : public MalwareDetails { request_context_getter_ = request_context_getter; } + private: virtual ~MalwareDetailsWrap() {} }; class MockSafeBrowsingService : public SafeBrowsingService { public: MockSafeBrowsingService() {} - virtual ~MockSafeBrowsingService() {} // When the MalwareDetails is done, this is called. virtual void SendSerializedMalwareDetails(const std::string& serialized) { @@ -161,6 +161,8 @@ class MockSafeBrowsingService : public SafeBrowsingService { } private: + virtual ~MockSafeBrowsingService() {} + std::string serialized_; DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingService); }; diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc index 6ed95f0..b6d96ae 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc @@ -37,8 +37,6 @@ class FakeSafeBrowsingService : public SafeBrowsingService { public: FakeSafeBrowsingService() {} - virtual ~FakeSafeBrowsingService() {} - // Called on the IO thread to check if the given url is safe or not. If we // can synchronously determine that the url is safe, CheckUrl returns true. // Otherwise it returns false, and "client" is called asynchronously with the @@ -89,6 +87,8 @@ class FakeSafeBrowsingService : public SafeBrowsingService { std::vector<std::string> reports_; private: + virtual ~FakeSafeBrowsingService() {} + base::hash_map<std::string, UrlCheckResult> badurls; }; @@ -111,8 +111,6 @@ class FakeMalwareDetails : public MalwareDetails { const SafeBrowsingService::UnsafeResource& unsafe_resource) : MalwareDetails(sb_service, web_contents, unsafe_resource) { } - virtual ~FakeMalwareDetails() {} - virtual void AddDOMDetails( const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params) { EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -152,6 +150,8 @@ class FakeMalwareDetails : public MalwareDetails { } private: + virtual ~FakeMalwareDetails() {} + // Some logic to figure out if we should wait for the dom details or not. // These variables should only be accessed in the UI thread. bool got_dom_; diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc index 3d55889..6394fe6 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc @@ -47,8 +47,6 @@ class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { class TestSafeBrowsingService: public SafeBrowsingService { public: - virtual ~TestSafeBrowsingService() {} - virtual void SendSerializedMalwareDetails(const std::string& serialized) { details_.push_back(serialized); } @@ -57,6 +55,9 @@ class TestSafeBrowsingService: public SafeBrowsingService { return &details_; } + private: + virtual ~TestSafeBrowsingService() {} + std::list<std::string> details_; }; diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index de68cb3..100f22a 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -107,6 +107,8 @@ class SafeBrowsingURLRequestContext : public net::URLRequestContext { } private: + virtual ~SafeBrowsingURLRequestContext() {} + base::debug::LeakTracker<SafeBrowsingURLRequestContext> leak_tracker_; }; diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc index a330994..5ad620b 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc @@ -506,9 +506,9 @@ class TestSBClient : public base::RefCountedThreadSafe<TestSBClient>, public SafeBrowsingService::Client { public: - TestSBClient() : result_(SafeBrowsingService::SAFE), - safe_browsing_service_(g_browser_process-> - safe_browsing_service()) { + TestSBClient() + : result_(SafeBrowsingService::SAFE), + safe_browsing_service_(g_browser_process->safe_browsing_service()) { } int GetResult() { @@ -532,6 +532,9 @@ class TestSBClient } private: + friend class base::RefCountedThreadSafe<TestSBClient>; + virtual ~TestSBClient() {} + void CheckDownloadUrlOnIOThread(const std::vector<GURL>& url_chain) { safe_browsing_service_->CheckDownloadUrl(url_chain, this); } diff --git a/chrome/browser/safe_browsing/safe_browsing_test.cc b/chrome/browser/safe_browsing/safe_browsing_test.cc index 3983e83..393a50f 100644 --- a/chrome/browser/safe_browsing/safe_browsing_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_test.cc @@ -515,6 +515,9 @@ class SafeBrowsingServiceTestHelper } private: + friend class base::RefCountedThreadSafe<SafeBrowsingServiceTestHelper>; + virtual ~SafeBrowsingServiceTestHelper() {} + // Stops UI loop after desired status is updated. void StopUILoop() { EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); diff --git a/chrome/browser/speech/speech_input_extension_api.cc b/chrome/browser/speech/speech_input_extension_api.cc index 71711f0..23afea0 100644 --- a/chrome/browser/speech/speech_input_extension_api.cc +++ b/chrome/browser/speech/speech_input_extension_api.cc @@ -42,8 +42,7 @@ SpeechInputAsyncFunction::SpeechInputAsyncFunction( content::Source<Profile>(profile())); } -SpeechInputAsyncFunction::~SpeechInputAsyncFunction() { -} +SpeechInputAsyncFunction::~SpeechInputAsyncFunction() {} void SpeechInputAsyncFunction::Run() { if (failed_) { diff --git a/chrome/browser/speech/speech_input_extension_api.h b/chrome/browser/speech/speech_input_extension_api.h index c3f6135..fd7fba3 100644 --- a/chrome/browser/speech/speech_input_extension_api.h +++ b/chrome/browser/speech/speech_input_extension_api.h @@ -13,20 +13,22 @@ // recognition in the framework of the extension API state machine. class SpeechInputAsyncFunction : public AsyncExtensionFunction, public content::NotificationObserver { + public: + // content::NotificationObserver. + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + protected: SpeechInputAsyncFunction(int start_state, int transition_state, int end_state, int transition_notification); virtual ~SpeechInputAsyncFunction(); + // ExtensionFunction: virtual void Run() OVERRIDE; virtual bool RunImpl() = 0; private: - // content::NotificationObserver. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - // To be defined on construction by derived classes. int start_state_; int transition_state_; @@ -41,35 +43,48 @@ class SpeechInputAsyncFunction : public AsyncExtensionFunction, // Implements experimental.speechInput.start. class StartSpeechInputFunction : public SpeechInputAsyncFunction { public: + DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.start"); + StartSpeechInputFunction(); - virtual ~StartSpeechInputFunction() {} protected: + // SpeechInputAsyncFunction: virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.start"); + + private: + virtual ~StartSpeechInputFunction() {} }; // Implements experimental.speechInput.stop. class StopSpeechInputFunction : public SpeechInputAsyncFunction { public: + DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.stop"); + StopSpeechInputFunction(); - virtual ~StopSpeechInputFunction() {} protected: + // SpeechInputAsyncFunction: virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.stop"); + + private: + virtual ~StopSpeechInputFunction() {} }; // Implements experimental.speechInput.isRecording. class IsRecordingSpeechInputFunction : public SyncExtensionFunction { public: + DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.isRecording"); + // Called back from SpeechInputExtensionManager in the UI thread. void SetResult(bool result); protected: + // ExtensionFunction: virtual void Run() OVERRIDE; virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.isRecording"); + + private: + virtual ~IsRecordingSpeechInputFunction() {} }; #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_API_H_ diff --git a/chrome/browser/speech/speech_recognition_bubble_controller.cc b/chrome/browser/speech/speech_recognition_bubble_controller.cc index fc66279..c03d019 100644 --- a/chrome/browser/speech/speech_recognition_bubble_controller.cc +++ b/chrome/browser/speech/speech_recognition_bubble_controller.cc @@ -25,10 +25,6 @@ SpeechRecognitionBubbleController::SpeechRecognitionBubbleController( registrar_(new content::NotificationRegistrar) { } -SpeechRecognitionBubbleController::~SpeechRecognitionBubbleController() { - DCHECK(bubbles_.empty()); -} - void SpeechRecognitionBubbleController::CreateBubble( int session_id, int render_process_id, @@ -65,10 +61,6 @@ void SpeechRecognitionBubbleController::CreateBubble( UpdateTabContentsSubscription(session_id, BUBBLE_ADDED); } -void SpeechRecognitionBubbleController::CloseBubble(int session_id) { - ProcessRequestInUiThread(session_id, REQUEST_CLOSE, string16(), 0, 0); -} - void SpeechRecognitionBubbleController::SetBubbleWarmUpMode(int session_id) { ProcessRequestInUiThread(session_id, REQUEST_SET_WARM_UP_MODE, string16(), 0, 0); @@ -85,42 +77,45 @@ void SpeechRecognitionBubbleController::SetBubbleRecognizingMode( string16(), 0, 0); } +void SpeechRecognitionBubbleController::SetBubbleMessage(int session_id, + const string16& text) { + ProcessRequestInUiThread(session_id, REQUEST_SET_MESSAGE, text, 0, 0); +} + void SpeechRecognitionBubbleController::SetBubbleInputVolume( int session_id, float volume, float noise_volume) { ProcessRequestInUiThread(session_id, REQUEST_SET_INPUT_VOLUME, string16(), volume, noise_volume); } -void SpeechRecognitionBubbleController::SetBubbleMessage(int session_id, - const string16& text) { - ProcessRequestInUiThread(session_id, REQUEST_SET_MESSAGE, text, 0, 0); +void SpeechRecognitionBubbleController::CloseBubble(int session_id) { + ProcessRequestInUiThread(session_id, REQUEST_CLOSE, string16(), 0, 0); } -void SpeechRecognitionBubbleController::UpdateTabContentsSubscription( - int session_id, ManageSubscriptionAction action) { +void SpeechRecognitionBubbleController::InfoBubbleButtonClicked( + SpeechRecognitionBubble::Button button) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(current_bubble_session_id_); - // If there are any other bubbles existing for the same WebContents, we would - // have subscribed to tab close notifications on their behalf and we need to - // stay registered. So we don't change the subscription in such cases. - WebContents* web_contents = bubbles_[session_id]->GetWebContents(); - for (BubbleSessionIdMap::iterator iter = bubbles_.begin(); - iter != bubbles_.end(); ++iter) { - if (iter->second->GetWebContents() == web_contents && - iter->first != session_id) { - // At least one other bubble exists for the same WebContents. So don't - // make any change to the subscription. - return; - } - } + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind( + &SpeechRecognitionBubbleController::InvokeDelegateButtonClicked, + this, current_bubble_session_id_, button)); +} - if (action == BUBBLE_ADDED) { - registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, - content::Source<WebContents>(web_contents)); - } else { - registrar_->Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, - content::Source<WebContents>(web_contents)); - } +void SpeechRecognitionBubbleController::InfoBubbleFocusChanged() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(current_bubble_session_id_); + + int old_bubble_session_id = current_bubble_session_id_; + current_bubble_session_id_ = 0; + + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind( + &SpeechRecognitionBubbleController::InvokeDelegateFocusChanged, + this, old_bubble_session_id)); } void SpeechRecognitionBubbleController::Observe( @@ -150,6 +145,20 @@ void SpeechRecognitionBubbleController::Observe( } } +SpeechRecognitionBubbleController::~SpeechRecognitionBubbleController() { + DCHECK(bubbles_.empty()); +} + +void SpeechRecognitionBubbleController::InvokeDelegateButtonClicked( + int session_id, SpeechRecognitionBubble::Button button) { + delegate_->InfoBubbleButtonClicked(session_id, button); +} + +void SpeechRecognitionBubbleController::InvokeDelegateFocusChanged( + int session_id) { + delegate_->InfoBubbleFocusChanged(session_id); +} + void SpeechRecognitionBubbleController::ProcessRequestInUiThread( int session_id, RequestType type, const string16& text, float volume, float noise_volume) { @@ -206,40 +215,31 @@ void SpeechRecognitionBubbleController::ProcessRequestInUiThread( bubble->Show(); } -void SpeechRecognitionBubbleController::InfoBubbleButtonClicked( - SpeechRecognitionBubble::Button button) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(current_bubble_session_id_); - - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind( - &SpeechRecognitionBubbleController::InvokeDelegateButtonClicked, - this, current_bubble_session_id_, button)); -} - -void SpeechRecognitionBubbleController::InfoBubbleFocusChanged() { +void SpeechRecognitionBubbleController::UpdateTabContentsSubscription( + int session_id, ManageSubscriptionAction action) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(current_bubble_session_id_); - - int old_bubble_session_id = current_bubble_session_id_; - current_bubble_session_id_ = 0; - - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind( - &SpeechRecognitionBubbleController::InvokeDelegateFocusChanged, - this, old_bubble_session_id)); -} -void SpeechRecognitionBubbleController::InvokeDelegateButtonClicked( - int session_id, SpeechRecognitionBubble::Button button) { - delegate_->InfoBubbleButtonClicked(session_id, button); -} + // If there are any other bubbles existing for the same WebContents, we would + // have subscribed to tab close notifications on their behalf and we need to + // stay registered. So we don't change the subscription in such cases. + WebContents* web_contents = bubbles_[session_id]->GetWebContents(); + for (BubbleSessionIdMap::iterator iter = bubbles_.begin(); + iter != bubbles_.end(); ++iter) { + if (iter->second->GetWebContents() == web_contents && + iter->first != session_id) { + // At least one other bubble exists for the same WebContents. So don't + // make any change to the subscription. + return; + } + } -void SpeechRecognitionBubbleController::InvokeDelegateFocusChanged( - int session_id) { - delegate_->InfoBubbleFocusChanged(session_id); + if (action == BUBBLE_ADDED) { + registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents)); + } else { + registrar_->Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents)); + } } } // namespace speech diff --git a/chrome/browser/speech/speech_recognition_bubble_controller.h b/chrome/browser/speech/speech_recognition_bubble_controller.h index 744cb64..1f59d08 100644 --- a/chrome/browser/speech/speech_recognition_bubble_controller.h +++ b/chrome/browser/speech/speech_recognition_bubble_controller.h @@ -49,7 +49,6 @@ class SpeechRecognitionBubbleController }; explicit SpeechRecognitionBubbleController(Delegate* delegate); - virtual ~SpeechRecognitionBubbleController(); // Creates a new speech recognition UI bubble. One of the SetXxxx methods // below need to be called to specify what to display. @@ -90,6 +89,8 @@ class SpeechRecognitionBubbleController const content::NotificationDetails& details) OVERRIDE; private: + friend class base::RefCountedThreadSafe<SpeechRecognitionBubbleController>; + // The various calls received by this object and handled in the UI thread. enum RequestType { REQUEST_SET_WARM_UP_MODE, @@ -105,6 +106,8 @@ class SpeechRecognitionBubbleController BUBBLE_REMOVED }; + virtual ~SpeechRecognitionBubbleController(); + void InvokeDelegateButtonClicked(int session_id, SpeechRecognitionBubble::Button button); void InvokeDelegateFocusChanged(int session_id); diff --git a/chrome/browser/spellchecker/spellcheck_message_filter.cc b/chrome/browser/spellchecker/spellcheck_message_filter.cc index ad90df1a..eb76417 100644 --- a/chrome/browser/spellchecker/spellcheck_message_filter.cc +++ b/chrome/browser/spellchecker/spellcheck_message_filter.cc @@ -25,9 +25,6 @@ SpellCheckMessageFilter::SpellCheckMessageFilter(int render_process_id) document_tag_(0) { } -SpellCheckMessageFilter::~SpellCheckMessageFilter() { -} - void SpellCheckMessageFilter::OverrideThreadForMessage( const IPC::Message& message, BrowserThread::ID* thread) { if (message.type() == SpellCheckHostMsg_RequestDictionary::ID || @@ -56,6 +53,8 @@ bool SpellCheckMessageFilter::OnMessageReceived(const IPC::Message& message, return handled; } +SpellCheckMessageFilter::~SpellCheckMessageFilter() {} + void SpellCheckMessageFilter::OnSpellCheckerRequestDictionary() { content::RenderProcessHost* host = content::RenderProcessHost::FromID(render_process_id_); diff --git a/chrome/browser/spellchecker/spellcheck_message_filter.h b/chrome/browser/spellchecker/spellcheck_message_filter.h index 23e26d2..5b3926e 100644 --- a/chrome/browser/spellchecker/spellcheck_message_filter.h +++ b/chrome/browser/spellchecker/spellcheck_message_filter.h @@ -18,7 +18,6 @@ class SpellingServiceClient; class SpellCheckMessageFilter : public content::BrowserMessageFilter { public: explicit SpellCheckMessageFilter(int render_process_id); - virtual ~SpellCheckMessageFilter(); // content::BrowserMessageFilter implementation. virtual void OverrideThreadForMessage( @@ -28,6 +27,8 @@ class SpellCheckMessageFilter : public content::BrowserMessageFilter { bool* message_was_ok) OVERRIDE; private: + virtual ~SpellCheckMessageFilter(); + void OnSpellCheckerRequestDictionary(); void OnNotifyChecked(const string16& word, bool misspelled); #if !defined(OS_MACOSX) diff --git a/chrome/browser/spellchecker/spellcheck_message_filter_mac.cc b/chrome/browser/spellchecker/spellcheck_message_filter_mac.cc index 4a5976a4..8a947be 100644 --- a/chrome/browser/spellchecker/spellcheck_message_filter_mac.cc +++ b/chrome/browser/spellchecker/spellcheck_message_filter_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,11 +9,7 @@ using content::BrowserThread; -SpellCheckMessageFilterMac::SpellCheckMessageFilterMac() { -} - -SpellCheckMessageFilterMac::~SpellCheckMessageFilterMac() { -} +SpellCheckMessageFilterMac::SpellCheckMessageFilterMac() {} bool SpellCheckMessageFilterMac::OnMessageReceived(const IPC::Message& message, bool* message_was_ok) { @@ -37,6 +33,8 @@ bool SpellCheckMessageFilterMac::OnMessageReceived(const IPC::Message& message, return handled; } +SpellCheckMessageFilterMac::~SpellCheckMessageFilterMac() {} + void SpellCheckMessageFilterMac::OnCheckSpelling(const string16& word, int tag, bool* correct) { diff --git a/chrome/browser/spellchecker/spellcheck_message_filter_mac.h b/chrome/browser/spellchecker/spellcheck_message_filter_mac.h index bf75fd9..0ccc8f8 100644 --- a/chrome/browser/spellchecker/spellcheck_message_filter_mac.h +++ b/chrome/browser/spellchecker/spellcheck_message_filter_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,13 +12,16 @@ class SpellCheckMessageFilterMac : public content::BrowserMessageFilter { public: explicit SpellCheckMessageFilterMac(); - virtual ~SpellCheckMessageFilterMac(); // BrowserMessageFilter implementation. virtual bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok) OVERRIDE; private: + friend class TestingSpellCheckMessageFilter; + + virtual ~SpellCheckMessageFilterMac(); + void OnCheckSpelling(const string16& word, int tag, bool* correct); void OnFillSuggestionList(const string16& word, std::vector<string16>* suggestions); diff --git a/chrome/browser/spellchecker/spellcheck_message_filter_mac_browsertest.cc b/chrome/browser/spellchecker/spellcheck_message_filter_mac_browsertest.cc index d858e69..3b962d1 100644 --- a/chrome/browser/spellchecker/spellcheck_message_filter_mac_browsertest.cc +++ b/chrome/browser/spellchecker/spellcheck_message_filter_mac_browsertest.cc @@ -13,10 +13,6 @@ #include "chrome/test/base/ui_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { - -typedef InProcessBrowserTest SpellCheckMessageFilterMacBrowserTest; - // Fake filter for testing, which stores sent messages and // allows verification by the test case. class TestingSpellCheckMessageFilter : public SpellCheckMessageFilterMac { @@ -25,10 +21,6 @@ class TestingSpellCheckMessageFilter : public SpellCheckMessageFilterMac { : SpellCheckMessageFilterMac(), loop_(loop) { } - ~TestingSpellCheckMessageFilter() { - STLDeleteContainerPointers(sent_messages_.begin(), sent_messages_.end()); - } - virtual bool Send(IPC::Message* message) { sent_messages_.push_back(message); loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); @@ -37,8 +29,15 @@ class TestingSpellCheckMessageFilter : public SpellCheckMessageFilterMac { std::vector<IPC::Message*> sent_messages_; MessageLoopForUI* loop_; + + private: + ~TestingSpellCheckMessageFilter() { + STLDeleteContainerPointers(sent_messages_.begin(), sent_messages_.end()); + } }; +typedef InProcessBrowserTest SpellCheckMessageFilterMacBrowserTest; + // Uses browsertest to setup chrome threads. IN_PROC_BROWSER_TEST_F(SpellCheckMessageFilterMacBrowserTest, SpellCheckReturnMessage) { @@ -66,5 +65,3 @@ IN_PROC_BROWSER_TEST_F(SpellCheckMessageFilterMacBrowserTest, EXPECT_EQ(sent_results[0].type, SpellCheckResult::SPELLING); } - -} // namespace |