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

Side by Side Diff: content/child/npapi/np_channel_base.h

Issue 1142063003: content/child: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix. Created 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ 5 #ifndef CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_
6 #define CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ 6 #define CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/process/process.h" 14 #include "base/process/process.h"
15 #include "content/child/npapi/npobject_base.h" 15 #include "content/child/npapi/npobject_base.h"
16 #include "content/common/message_router.h" 16 #include "content/common/message_router.h"
17 #include "ipc/ipc_channel_handle.h" 17 #include "ipc/ipc_channel_handle.h"
18 #include "ipc/ipc_sync_channel.h" 18 #include "ipc/ipc_sync_channel.h"
19 19
20 namespace base { 20 namespace base {
21 class MessageLoopProxy; 21 class SingleThreadTaskRunner;
22 } 22 }
23 23
24 namespace content { 24 namespace content {
25 25
26 // Encapsulates an IPC channel between a renderer and another process. Used to 26 // Encapsulates an IPC channel between a renderer and another process. Used to
27 // proxy access to NP objects. 27 // proxy access to NP objects.
28 class NPChannelBase : public IPC::Listener, 28 class NPChannelBase : public IPC::Listener,
29 public IPC::Sender, 29 public IPC::Sender,
30 public base::RefCountedThreadSafe<NPChannelBase> { 30 public base::RefCountedThreadSafe<NPChannelBase> {
31 public: 31 public:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 friend class base::RefCountedThreadSafe<NPChannelBase>; 93 friend class base::RefCountedThreadSafe<NPChannelBase>;
94 94
95 ~NPChannelBase() override; 95 ~NPChannelBase() override;
96 96
97 // Returns a NPChannelBase derived object for the given channel name. 97 // Returns a NPChannelBase derived object for the given channel name.
98 // If an existing channel exists returns that object, otherwise creates a 98 // If an existing channel exists returns that object, otherwise creates a
99 // new one. Even though on creation the object is refcounted, each caller 99 // new one. Even though on creation the object is refcounted, each caller
100 // must still ref count the returned value. When there are no more routes 100 // must still ref count the returned value. When there are no more routes
101 // on the channel and its ref count is 0, the object deletes itself. 101 // on the channel and its ref count is 0, the object deletes itself.
102 static NPChannelBase* GetChannel( 102 static NPChannelBase* GetChannel(
103 const IPC::ChannelHandle& channel_handle, IPC::Channel::Mode mode, 103 const IPC::ChannelHandle& channel_handle,
104 ChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, 104 IPC::Channel::Mode mode,
105 bool create_pipe_now, base::WaitableEvent* shutdown_event); 105 ChannelFactory factory,
106 base::SingleThreadTaskRunner* ipc_task_runner,
107 bool create_pipe_now,
108 base::WaitableEvent* shutdown_event);
106 109
107 // Sends a message to all instances. 110 // Sends a message to all instances.
108 static void Broadcast(IPC::Message* message); 111 static void Broadcast(IPC::Message* message);
109 112
110 // Called on the worker thread 113 // Called on the worker thread
111 NPChannelBase(); 114 NPChannelBase();
112 115
113 virtual void CleanUp() { } 116 virtual void CleanUp() { }
114 117
115 // Implemented by derived classes to handle control messages 118 // Implemented by derived classes to handle control messages
116 virtual bool OnControlMessageReceived(const IPC::Message& msg); 119 virtual bool OnControlMessageReceived(const IPC::Message& msg);
117 120
118 // IPC::Listener implementation: 121 // IPC::Listener implementation:
119 bool OnMessageReceived(const IPC::Message& msg) override; 122 bool OnMessageReceived(const IPC::Message& msg) override;
120 void OnChannelConnected(int32 peer_pid) override; 123 void OnChannelConnected(int32 peer_pid) override;
121 void OnChannelError() override; 124 void OnChannelError() override;
122 125
123 void set_send_unblocking_only_during_unblock_dispatch() { 126 void set_send_unblocking_only_during_unblock_dispatch() {
124 send_unblocking_only_during_unblock_dispatch_ = true; 127 send_unblocking_only_during_unblock_dispatch_ = true;
125 } 128 }
126 129
127 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, 130 virtual bool Init(base::SingleThreadTaskRunner* ipc_task_runner,
128 bool create_pipe_now, 131 bool create_pipe_now,
129 base::WaitableEvent* shutdown_event); 132 base::WaitableEvent* shutdown_event);
130 133
131 scoped_ptr<IPC::SyncChannel> channel_; 134 scoped_ptr<IPC::SyncChannel> channel_;
132 IPC::ChannelHandle channel_handle_; 135 IPC::ChannelHandle channel_handle_;
133 136
134 private: 137 private:
135 IPC::Channel::Mode mode_; 138 IPC::Channel::Mode mode_;
136 // This tracks the number of routes registered without an NPObject. It's used 139 // This tracks the number of routes registered without an NPObject. It's used
137 // to manage the lifetime of this object. See comment for AddRoute() and 140 // to manage the lifetime of this object. See comment for AddRoute() and
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // have the unblock flag set, since they could be followed by a sync message 189 // have the unblock flag set, since they could be followed by a sync message
187 // that won't get dispatched until the call to the renderer is complete. 190 // that won't get dispatched until the call to the renderer is complete.
188 bool send_unblocking_only_during_unblock_dispatch_; 191 bool send_unblocking_only_during_unblock_dispatch_;
189 192
190 DISALLOW_COPY_AND_ASSIGN(NPChannelBase); 193 DISALLOW_COPY_AND_ASSIGN(NPChannelBase);
191 }; 194 };
192 195
193 } // namespace content 196 } // namespace content
194 197
195 #endif // CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_ 198 #endif // CONTENT_CHILD_NPAPI_NP_CHANNEL_BASE_H_
OLDNEW
« no previous file with comments | « content/child/indexed_db/webidbcursor_impl_unittest.cc ('k') | content/child/npapi/np_channel_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698