diff options
author | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 01:25:11 +0000 |
---|---|---|
committer | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 01:25:11 +0000 |
commit | 7e5f8660e4fcc7ded0b316865a5063d3256b63b3 (patch) | |
tree | 710e4a5d93e2a11cae6a520761c78054f2c22e27 | |
parent | 9d37f0633b40007ea768c2f08e2a5cc01413ccf7 (diff) | |
download | chromium_src-7e5f8660e4fcc7ded0b316865a5063d3256b63b3.zip chromium_src-7e5f8660e4fcc7ded0b316865a5063d3256b63b3.tar.gz chromium_src-7e5f8660e4fcc7ded0b316865a5063d3256b63b3.tar.bz2 |
Cleanup pass from Cloud Print Proxy policy check implementation. See original CL at http://codereview.chromium.org/8438020/
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8620001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111068 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 25 insertions, 29 deletions
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 63766e9..7b31d31 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc @@ -165,8 +165,8 @@ void CloudPrintProxyService::TokenExpiredNotificationDone(bool keep_alive) { void CloudPrintProxyService::ApplyCloudPrintConnectorPolicy() { if (!profile_->GetPrefs()->GetBoolean(prefs::kCloudPrintProxyEnabled)) { - std::string email; - email = profile_->GetPrefs()->GetString(prefs::kCloudPrintEmail); + std::string email = + profile_->GetPrefs()->GetString(prefs::kCloudPrintEmail); if (!email.empty()) { DisableForUser(); profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string()); @@ -183,17 +183,14 @@ void CloudPrintProxyService::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - if (type == chrome::NOTIFICATION_PREF_CHANGED) { - ApplyCloudPrintConnectorPolicy(); - } else { - NOTREACHED(); - } + DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); + ApplyCloudPrintConnectorPolicy(); } void CloudPrintProxyService::RefreshCloudPrintProxyStatus() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); ServiceProcessControl* process_control = GetServiceProcessControl(); - DCHECK(process_control->is_connected()); + DCHECK(process_control->IsConnected()); ServiceProcessControl::CloudPrintProxyInfoHandler callback = base::Bind(&CloudPrintProxyService::ProxyInfoCallback, base::Unretained(this)); @@ -204,7 +201,7 @@ void CloudPrintProxyService::RefreshCloudPrintProxyStatus() { void CloudPrintProxyService::EnableCloudPrintProxy(const std::string& lsid, const std::string& email) { ServiceProcessControl* process_control = GetServiceProcessControl(); - DCHECK(process_control->is_connected()); + DCHECK(process_control->IsConnected()); process_control->Send(new ServiceMsg_EnableCloudPrintProxy(lsid)); // Assume the IPC worked. profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, email); @@ -215,7 +212,7 @@ void CloudPrintProxyService::EnableCloudPrintProxyWithRobot( const std::string& robot_email, const std::string& user_email) { ServiceProcessControl* process_control = GetServiceProcessControl(); - DCHECK(process_control->is_connected()); + DCHECK(process_control->IsConnected()); process_control->Send(new ServiceMsg_EnableCloudPrintProxyWithRobot( robot_auth_code, robot_email, @@ -226,7 +223,7 @@ void CloudPrintProxyService::EnableCloudPrintProxyWithRobot( void CloudPrintProxyService::DisableCloudPrintProxy() { ServiceProcessControl* process_control = GetServiceProcessControl(); - DCHECK(process_control->is_connected()); + DCHECK(process_control->IsConnected()); process_control->Send(new ServiceMsg_DisableCloudPrintProxy); // Assume the IPC worked. profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string()); diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc b/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc index 4f69a35..efa0088 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc @@ -34,7 +34,7 @@ class MockServiceProcessControl : public ServiceProcessControl { MockServiceProcessControl() : connected_(false) { } - MOCK_CONST_METHOD0(is_connected, bool()); + MOCK_CONST_METHOD0(IsConnected, bool()); MOCK_METHOD2(Launch, void(const base::Closure&, const base::Closure&)); MOCK_METHOD0(Disconnect, void()); @@ -78,7 +78,7 @@ void CallTask(const base::Closure& task) { void MockServiceProcessControl::SetConnectSuccessMockExpectations( ServiceState service_state) { - EXPECT_CALL(*this, is_connected()).WillRepeatedly(ReturnPointee(&connected_)); + EXPECT_CALL(*this, IsConnected()).WillRepeatedly(ReturnPointee(&connected_)); EXPECT_CALL(*this, Launch(_, _)) .WillRepeatedly( @@ -181,13 +181,13 @@ TEST_F(CloudPrintProxyPolicyTest, VerifyExpectations) { mock_control.SetConnectSuccessMockExpectations( MockServiceProcessControl::kServiceStateNone); - EXPECT_FALSE(mock_control.is_connected()); + EXPECT_FALSE(mock_control.IsConnected()); mock_control.Launch(base::Closure(), base::Closure()); - EXPECT_TRUE(mock_control.is_connected()); + EXPECT_TRUE(mock_control.IsConnected()); mock_control.Launch(base::Closure(), base::Closure()); - EXPECT_TRUE(mock_control.is_connected()); + EXPECT_TRUE(mock_control.IsConnected()); mock_control.Disconnect(); - EXPECT_FALSE(mock_control.is_connected()); + EXPECT_FALSE(mock_control.IsConnected()); } TEST_F(CloudPrintProxyPolicyTest, StartWithNoPolicyProxyDisabled) { diff --git a/chrome/browser/printing/cloud_print/virtual_driver_install_helper.cc b/chrome/browser/printing/cloud_print/virtual_driver_install_helper.cc index 372332d..8316098 100644 --- a/chrome/browser/printing/cloud_print/virtual_driver_install_helper.cc +++ b/chrome/browser/printing/cloud_print/virtual_driver_install_helper.cc @@ -31,16 +31,15 @@ void VirtualDriverInstallHelper::SetUpUninstall() { void VirtualDriverInstallHelper::InstallVirtualDriverTask() { ServiceProcessControl* process_control = ServiceProcessControl::GetInstance(); - DCHECK(process_control->is_connected()); + DCHECK(process_control->IsConnected()); process_control->Send(new ServiceMsg_EnableVirtualDriver()); } void VirtualDriverInstallHelper::UninstallVirtualDriverTask() { ServiceProcessControl* process_control = ServiceProcessControl::GetInstance(); - DCHECK(process_control->is_connected()); + DCHECK(process_control->IsConnected()); process_control->Send(new ServiceMsg_DisableVirtualDriver()); } } // namespace cloud_print - diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc index f92e3dd..c59fee1 100644 --- a/chrome/browser/service/service_process_control.cc +++ b/chrome/browser/service/service_process_control.cc @@ -56,7 +56,7 @@ void ServiceProcessControl::RunConnectDoneTasks() { // avoided. TaskList tasks; - if (is_connected()) { + if (IsConnected()) { tasks.swap(connect_success_tasks_); RunAllTasksHelper(&tasks); DCHECK(tasks.empty()); @@ -78,8 +78,8 @@ void ServiceProcessControl::RunAllTasksHelper(TaskList* task_list) { } } -bool ServiceProcessControl::is_connected() const { - return channel_.get() != NULL; +bool ServiceProcessControl::IsConnected() const { + return channel_ != NULL; } void ServiceProcessControl::Launch(const base::Closure& success_task, diff --git a/chrome/browser/service/service_process_control.h b/chrome/browser/service/service_process_control.h index c6d8dd5..51929da 100644 --- a/chrome/browser/service/service_process_control.h +++ b/chrome/browser/service/service_process_control.h @@ -51,7 +51,7 @@ class ServiceProcessControl : public IPC::Channel::Sender, // Return true if this object is connected to the service. // Virtual for testing. - virtual bool is_connected() const; + virtual bool IsConnected() const; // If no service process is currently running, creates a new service process // and connects to it. If a service process is already running this method diff --git a/chrome/browser/service/service_process_control_browsertest.cc b/chrome/browser/service/service_process_control_browsertest.cc index 84393e5..d82be6a 100644 --- a/chrome/browser/service/service_process_control_browsertest.cc +++ b/chrome/browser/service/service_process_control_browsertest.cc @@ -101,7 +101,7 @@ IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, LaunchServiceProcessControl(); // Make sure we are connected to the service process. - EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); + EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); SendRequestAndWait(); // And then shutdown the service process. @@ -115,12 +115,12 @@ IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, LaunchTwice) { LaunchServiceProcessControl(); // Make sure we are connected to the service process. - EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); + EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); SendRequestAndWait(); // Launch the service process again. LaunchServiceProcessControl(); - EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); + EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); SendRequestAndWait(); // And then shutdown the service process. @@ -174,7 +174,7 @@ IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, // Launch the service process. LaunchServiceProcessControl(); // Make sure we are connected to the service process. - EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); + EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); Disconnect(); WaitForShutdown(); } @@ -184,7 +184,7 @@ IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, // Launch the service process. LaunchServiceProcessControl(); // Make sure we are connected to the service process. - EXPECT_TRUE(ServiceProcessControl::GetInstance()->is_connected()); + EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); base::ProcessId service_pid; EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |