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

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

Issue 10541065: Separate out IPC::Message::Sender and channel::Listener into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: de-inline Created 8 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/memory/singleton.h" 17 #include "base/memory/singleton.h"
18 #include "base/process.h" 18 #include "base/process.h"
19 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 #include "ipc/ipc_channel_proxy.h" 21 #include "ipc/ipc_channel_proxy.h"
22 #include "ipc/ipc_listener.h"
23 #include "ipc/ipc_sender.h"
22 24
23 class CommandLine; 25 class CommandLine;
24 26
25 namespace cloud_print { 27 namespace cloud_print {
26 struct CloudPrintProxyInfo; 28 struct CloudPrintProxyInfo;
27 } // namespace cloud_print 29 } // namespace cloud_print
28 30
29 // A ServiceProcessControl works as a portal between the service process and 31 // A ServiceProcessControl works as a portal between the service process and
30 // the browser process. 32 // the browser process.
31 // 33 //
32 // It is used to start and terminate the service process. It is also used 34 // It is used to start and terminate the service process. It is also used
33 // to send and receive IPC messages from the service process. 35 // to send and receive IPC messages from the service process.
34 // 36 //
35 // THREADING 37 // THREADING
36 // 38 //
37 // This class is accessed on the UI thread through some UI actions. It then 39 // This class is accessed on the UI thread through some UI actions. It then
38 // talks to the IPC channel on the IO thread. 40 // talks to the IPC channel on the IO thread.
39 class ServiceProcessControl : public IPC::Channel::Sender, 41 class ServiceProcessControl : public IPC::Sender,
40 public IPC::Channel::Listener, 42 public IPC::Listener,
41 public content::NotificationObserver { 43 public content::NotificationObserver {
42 public: 44 public:
43 typedef IDMap<ServiceProcessControl>::iterator iterator; 45 typedef IDMap<ServiceProcessControl>::iterator iterator;
44 typedef std::queue<IPC::Message> MessageQueue; 46 typedef std::queue<IPC::Message> MessageQueue;
45 typedef base::Callback<void(const cloud_print::CloudPrintProxyInfo&)> 47 typedef base::Callback<void(const cloud_print::CloudPrintProxyInfo&)>
46 CloudPrintProxyInfoHandler; 48 CloudPrintProxyInfoHandler;
47 49
48 // Returns the singleton instance of this class. 50 // Returns the singleton instance of this class.
49 static ServiceProcessControl* GetInstance(); 51 static ServiceProcessControl* GetInstance();
50 52
(...skipping 12 matching lines...) Expand all
63 // Note that if we are already connected to service process then 65 // Note that if we are already connected to service process then
64 // |success_task| can be invoked in the context of the Launch call. 66 // |success_task| can be invoked in the context of the Launch call.
65 // Virtual for testing. 67 // Virtual for testing.
66 virtual void Launch(const base::Closure& success_task, 68 virtual void Launch(const base::Closure& success_task,
67 const base::Closure& failure_task); 69 const base::Closure& failure_task);
68 70
69 // Disconnect the IPC channel from the service process. 71 // Disconnect the IPC channel from the service process.
70 // Virtual for testing. 72 // Virtual for testing.
71 virtual void Disconnect(); 73 virtual void Disconnect();
72 74
73 // IPC::Channel::Listener implementation. 75 // IPC::Listener implementation.
74 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 76 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
75 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 77 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
76 virtual void OnChannelError() OVERRIDE; 78 virtual void OnChannelError() OVERRIDE;
77 79
78 // IPC::Channel::Sender implementation 80 // IPC::Sender implementation
79 virtual bool Send(IPC::Message* message) OVERRIDE; 81 virtual bool Send(IPC::Message* message) OVERRIDE;
80 82
81 // content::NotificationObserver implementation. 83 // content::NotificationObserver implementation.
82 virtual void Observe(int type, 84 virtual void Observe(int type,
83 const content::NotificationSource& source, 85 const content::NotificationSource& source,
84 const content::NotificationDetails& details) OVERRIDE; 86 const content::NotificationDetails& details) OVERRIDE;
85 87
86 // Message handlers 88 // Message handlers
87 void OnCloudPrintProxyInfo( 89 void OnCloudPrintProxyInfo(
88 const cloud_print::CloudPrintProxyInfo& proxy_info); 90 const cloud_print::CloudPrintProxyInfo& proxy_info);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 TaskList connect_failure_tasks_; 167 TaskList connect_failure_tasks_;
166 168
167 // Callback that gets invoked when a status message is received from 169 // Callback that gets invoked when a status message is received from
168 // the cloud print proxy. 170 // the cloud print proxy.
169 CloudPrintProxyInfoHandler cloud_print_info_callback_; 171 CloudPrintProxyInfoHandler cloud_print_info_callback_;
170 172
171 content::NotificationRegistrar registrar_; 173 content::NotificationRegistrar registrar_;
172 }; 174 };
173 175
174 #endif // CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_ 176 #endif // CHROME_BROWSER_SERVICE_SERVICE_PROCESS_CONTROL_H_
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider.h ('k') | content/browser/gpu/gpu_process_host_ui_shim.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698