diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-06 01:10:14 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-06 01:10:14 +0000 |
commit | 8ddbaac46292230ca3d8b5647e94d1a5bd4859ae (patch) | |
tree | 63d2a0d8e0be89a72b1dd46d83d74090fe29e71c /chrome/browser/service | |
parent | 176c18328ad6e115b7a191e09e09266671f9cac1 (diff) | |
download | chromium_src-8ddbaac46292230ca3d8b5647e94d1a5bd4859ae.zip chromium_src-8ddbaac46292230ca3d8b5647e94d1a5bd4859ae.tar.gz chromium_src-8ddbaac46292230ca3d8b5647e94d1a5bd4859ae.tar.bz2 |
Fixes for the Remoting setup flow.
1. Add gaia_login.html and setup_flow_error.html resources.
2. Add SetupFlowErrorStepBase for errors.
3. More flexible message handling.
4. Support for multiple message handlers in ServiceProcessControl.
BUG=67218
TEST=Unittests.
Review URL: http://codereview.chromium.org/6064006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/service')
-rw-r--r-- | chrome/browser/service/service_process_control.cc | 33 | ||||
-rw-r--r-- | chrome/browser/service/service_process_control.h | 36 | ||||
-rw-r--r-- | chrome/browser/service/service_process_control_browsertest.cc | 6 |
3 files changed, 46 insertions, 29 deletions
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc index ccce948..2873ddc 100644 --- a/chrome/browser/service/service_process_control.cc +++ b/chrome/browser/service/service_process_control.cc @@ -96,8 +96,7 @@ class ServiceProcessControl::Launcher // ServiceProcessControl implementation. ServiceProcessControl::ServiceProcessControl(Profile* profile) - : profile_(profile), - message_handler_(NULL) { + : profile_(profile) { } ServiceProcessControl::~ServiceProcessControl() { @@ -279,10 +278,11 @@ void ServiceProcessControl::Observe(NotificationType type, } void ServiceProcessControl::OnGoodDay() { - if (!message_handler_) - return; - - message_handler_->OnGoodDay(); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + for (std::set<MessageHandler*>::iterator it = message_handlers_.begin(); + it != message_handlers_.end(); ++it) { + (*it)->OnGoodDay(); + } } void ServiceProcessControl::OnCloudPrintProxyIsEnabled(bool enabled, @@ -297,9 +297,9 @@ void ServiceProcessControl::OnCloudPrintProxyIsEnabled(bool enabled, void ServiceProcessControl::OnRemotingHostInfo( remoting::ChromotingHostInfo host_info) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (remoting_host_status_callback_ != NULL) { - remoting_host_status_callback_->Run(host_info); - remoting_host_status_callback_.reset(); + for (std::set<MessageHandler*>::iterator it = message_handlers_.begin(); + it != message_handlers_.end(); ++it) { + (*it)->OnRemotingHostInfo(host_info); } } @@ -335,11 +335,18 @@ bool ServiceProcessControl::DisableRemotingHost() { return Send(new ServiceMsg_DisableRemotingHost()); } -bool ServiceProcessControl::GetRemotingHostStatus( - GetRemotingHostStatusCallback* status_callback) { - DCHECK(status_callback); - remoting_host_status_callback_.reset(status_callback); +bool ServiceProcessControl::RequestRemotingHostStatus() { return Send(new ServiceMsg_GetRemotingHostInfo); } +void ServiceProcessControl::AddMessageHandler( + MessageHandler* message_handler) { + message_handlers_.insert(message_handler); +} + +void ServiceProcessControl::RemoveMessageHandler( + MessageHandler* message_handler) { + message_handlers_.erase(message_handler); +} + DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); diff --git a/chrome/browser/service/service_process_control.h b/chrome/browser/service/service_process_control.h index 9162736..78c3141 100644 --- a/chrome/browser/service/service_process_control.h +++ b/chrome/browser/service/service_process_control.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ #include <queue> +#include <set> #include <string> #include <vector> @@ -41,15 +42,20 @@ class ServiceProcessControl : public IPC::Channel::Sender, typedef IDMap<ServiceProcessControl>::iterator iterator; typedef std::queue<IPC::Message> MessageQueue; typedef Callback1<const remoting::ChromotingHostInfo&>::Type - GetRemotingHostStatusCallback; + RemotingHostStatusHandler; // An interface for handling messages received from the service process. class MessageHandler { public: virtual ~MessageHandler() {} + // This is a test signal sent from the service process. This can be used // the healthiness of the service. virtual void OnGoodDay() = 0; + + // Called when we receive reply to remoting host status request. + virtual void OnRemotingHostInfo( + const remoting::ChromotingHostInfo& host_info) = 0; }; // Construct a ServiceProcessControl with |profile|.. @@ -103,29 +109,30 @@ class ServiceProcessControl : public IPC::Channel::Sender, // Return true if the message was sent. bool Shutdown(); - // Send a message to the service process to request a response - // containing the enablement status of the cloud print proxy and the - // registered email address. The callback gets the information when - // received. + // Send request for cloud print proxy status and the registered + // email address. The callback gets the information when received. bool GetCloudPrintProxyStatus( Callback2<bool, std::string>::Type* cloud_print_status_callback); // Send a message to enable the remoting service in the service process. // Return true if the message was sent. bool SetRemotingHostCredentials(const std::string& user, - const std::string& auth_token); + const std::string& auth_token); bool EnableRemotingHost(); bool DisableRemotingHost(); - bool GetRemotingHostStatus( - GetRemotingHostStatusCallback* status_callback); + // Send request for current status of the remoting service. + bool RequestRemotingHostStatus(); + + // Add a message handler for receiving messages from the service + // process. + void AddMessageHandler(MessageHandler* message_handler); - // Set the message handler for receiving messages from the service process. - // TODO(hclam): Allow more than 1 handler. - void SetMessageHandler(MessageHandler* message_handler) { - message_handler_ = message_handler; - } + // Remove a message handler from the list of message handlers. Must + // not be called from a message handler (i.e. while a message is + // being processed). + void RemoveMessageHandler(MessageHandler* message_handler); private: class Launcher; @@ -161,10 +168,9 @@ class ServiceProcessControl : public IPC::Channel::Sender, // Callback that gets invoked when a status message is received from // the cloud print proxy. scoped_ptr<Callback2<bool, std::string>::Type> cloud_print_status_callback_; - scoped_ptr<GetRemotingHostStatusCallback> remoting_host_status_callback_; // Handler for messages from service process. - MessageHandler* message_handler_; + std::set<MessageHandler*> message_handlers_; NotificationRegistrar registrar_; }; diff --git a/chrome/browser/service/service_process_control_browsertest.cc b/chrome/browser/service/service_process_control_browsertest.cc index 8cf596c..519c005 100644 --- a/chrome/browser/service/service_process_control_browsertest.cc +++ b/chrome/browser/service/service_process_control_browsertest.cc @@ -72,7 +72,7 @@ class ServiceProcessControlBrowserTest service_pid, base::kProcessAccessWaitForTermination, &service_process_handle_)); - process()->SetMessageHandler(this); + process()->AddMessageHandler(this); // Quit the current message. Post a QuitTask instead of just calling Quit() // because this can get invoked in the context of a Launch() call and we // may not be in Run() yet. @@ -90,6 +90,10 @@ class ServiceProcessControlBrowserTest MessageLoop::current()->Quit(); } + virtual void OnRemotingHostInfo( + const remoting::ChromotingHostInfo& host_info) { + } + ServiceProcessControl* process() { return process_; } private: |