Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/service/service_process_control.h

Issue 6955010: Remove the Remoting Host component from Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove an errant include. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ 5 #ifndef CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_
6 #define CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ 6 #define CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/id_map.h" 15 #include "base/id_map.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/process.h" 17 #include "base/process.h"
18 #include "base/task.h" 18 #include "base/task.h"
19 #include "content/common/notification_observer.h" 19 #include "content/common/notification_observer.h"
20 #include "content/common/notification_registrar.h" 20 #include "content/common/notification_registrar.h"
21 #include "ipc/ipc_sync_channel.h" 21 #include "ipc/ipc_sync_channel.h"
22 22
23 class Profile; 23 class Profile;
24 class CommandLine; 24 class CommandLine;
25 25
26 namespace remoting {
27 struct ChromotingHostInfo;
28 } // namespace remoting
29
30 // A ServiceProcessControl works as a portal between the service process and 26 // A ServiceProcessControl works as a portal between the service process and
31 // the browser process. 27 // the browser process.
32 // 28 //
33 // It is used to start and terminate the service process. It is also used 29 // It is used to start and terminate the service process. It is also used
34 // to send and receive IPC messages from the service process. 30 // to send and receive IPC messages from the service process.
35 // 31 //
36 // THREADING 32 // THREADING
37 // 33 //
38 // This class is accessed on the UI thread through some UI actions. It then 34 // This class is accessed on the UI thread through some UI actions. It then
39 // talks to the IPC channel on the IO thread. 35 // talks to the IPC channel on the IO thread.
40 class ServiceProcessControl : public IPC::Channel::Sender, 36 class ServiceProcessControl : public IPC::Channel::Sender,
41 public IPC::Channel::Listener, 37 public IPC::Channel::Listener,
42 public NotificationObserver { 38 public NotificationObserver {
43 public: 39 public:
44 typedef IDMap<ServiceProcessControl>::iterator iterator; 40 typedef IDMap<ServiceProcessControl>::iterator iterator;
45 typedef std::queue<IPC::Message> MessageQueue; 41 typedef std::queue<IPC::Message> MessageQueue;
46 typedef Callback1<const remoting::ChromotingHostInfo&>::Type
47 RemotingHostStatusHandler;
48
49 // An interface for handling messages received from the service process.
50 class MessageHandler {
51 public:
52 virtual ~MessageHandler() {}
53
54 // Called when we receive reply to remoting host status request.
55 virtual void OnRemotingHostInfo(
56 const remoting::ChromotingHostInfo& host_info) = 0;
57 };
58 42
59 // Construct a ServiceProcessControl with |profile|.. 43 // Construct a ServiceProcessControl with |profile|..
60 explicit ServiceProcessControl(Profile* profile); 44 explicit ServiceProcessControl(Profile* profile);
61 virtual ~ServiceProcessControl(); 45 virtual ~ServiceProcessControl();
62 46
63 // Return the user profile associated with this service process. 47 // Return the user profile associated with this service process.
64 Profile* profile() const { return profile_; } 48 Profile* profile() const { return profile_; }
65 49
66 // Return true if this object is connected to the service. 50 // Return true if this object is connected to the service.
67 bool is_connected() const { return channel_.get() != NULL; } 51 bool is_connected() const { return channel_.get() != NULL; }
(...skipping 20 matching lines...) Expand all
88 // IPC::Channel::Sender implementation 72 // IPC::Channel::Sender implementation
89 virtual bool Send(IPC::Message* message); 73 virtual bool Send(IPC::Message* message);
90 74
91 // NotificationObserver implementation. 75 // NotificationObserver implementation.
92 virtual void Observe(NotificationType type, 76 virtual void Observe(NotificationType type,
93 const NotificationSource& source, 77 const NotificationSource& source,
94 const NotificationDetails& details); 78 const NotificationDetails& details);
95 79
96 // Message handlers 80 // Message handlers
97 void OnCloudPrintProxyIsEnabled(bool enabled, std::string email); 81 void OnCloudPrintProxyIsEnabled(bool enabled, std::string email);
98 void OnRemotingHostInfo(const remoting::ChromotingHostInfo& host_info);
99 82
100 // Send a shutdown message to the service process. IPC channel will be 83 // Send a shutdown message to the service process. IPC channel will be
101 // destroyed after calling this method. 84 // destroyed after calling this method.
102 // Return true if the message was sent. 85 // Return true if the message was sent.
103 bool Shutdown(); 86 bool Shutdown();
104 87
105 // Send request for cloud print proxy status and the registered 88 // Send request for cloud print proxy status and the registered
106 // email address. The callback gets the information when received. 89 // email address. The callback gets the information when received.
107 bool GetCloudPrintProxyStatus( 90 bool GetCloudPrintProxyStatus(
108 Callback2<bool, std::string>::Type* cloud_print_status_callback); 91 Callback2<bool, std::string>::Type* cloud_print_status_callback);
109 92
110 // Send a message to enable the remoting service in the service process.
111 // Return true if the message was sent.
112 bool SetRemotingHostCredentials(const std::string& user,
113 const std::string& auth_token);
114
115 bool EnableRemotingHost();
116 bool DisableRemotingHost();
117
118 // Send request for current status of the remoting service.
119 // MessageHandler::OnRemotingHostInfo() will be called when remoting host
120 // status is available.
121 bool RequestRemotingHostStatus();
122
123 // Add a message handler for receiving messages from the service
124 // process.
125 void AddMessageHandler(MessageHandler* message_handler);
126
127 // Remove a message handler from the list of message handlers. Must
128 // not be called from a message handler (i.e. while a message is
129 // being processed).
130 void RemoveMessageHandler(MessageHandler* message_handler);
131
132 private: 93 private:
133 // This class is responsible for launching the service process on the 94 // This class is responsible for launching the service process on the
134 // PROCESS_LAUNCHER thread. 95 // PROCESS_LAUNCHER thread.
135 class Launcher 96 class Launcher
136 : public base::RefCountedThreadSafe<ServiceProcessControl::Launcher> { 97 : public base::RefCountedThreadSafe<ServiceProcessControl::Launcher> {
137 public: 98 public:
138 Launcher(ServiceProcessControl* process, CommandLine* cmd_line); 99 Launcher(ServiceProcessControl* process, CommandLine* cmd_line);
139 // Execute the command line to start the process asynchronously. 100 // Execute the command line to start the process asynchronously.
140 // After the comamnd is executed |task| is called with the process handle on 101 // After the comamnd is executed |task| is called with the process handle on
141 // the UI thread. 102 // the UI thread.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 TaskList connect_done_tasks_; 147 TaskList connect_done_tasks_;
187 // Callbacks that get invoked ONLY when the channel is successfully connected. 148 // Callbacks that get invoked ONLY when the channel is successfully connected.
188 TaskList connect_success_tasks_; 149 TaskList connect_success_tasks_;
189 // Callbacks that get invoked ONLY when there was a connection failure. 150 // Callbacks that get invoked ONLY when there was a connection failure.
190 TaskList connect_failure_tasks_; 151 TaskList connect_failure_tasks_;
191 152
192 // Callback that gets invoked when a status message is received from 153 // Callback that gets invoked when a status message is received from
193 // the cloud print proxy. 154 // the cloud print proxy.
194 scoped_ptr<Callback2<bool, std::string>::Type> cloud_print_status_callback_; 155 scoped_ptr<Callback2<bool, std::string>::Type> cloud_print_status_callback_;
195 156
196 // Handler for messages from service process.
197 std::set<MessageHandler*> message_handlers_;
198
199 NotificationRegistrar registrar_; 157 NotificationRegistrar registrar_;
200 }; 158 };
201 159
202 #endif // CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ 160 #endif // CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/advanced_options.js ('k') | chrome/browser/service/service_process_control.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698