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

Side by Side Diff: ppapi/proxy/ppapi_proxy_test.h

Issue 9187055: Reland 9034035: Make it possible to have 1 PpapiGlobals per thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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
« no previous file with comments | « ppapi/proxy/plugin_var_tracker.cc ('k') | ppapi/proxy/ppapi_proxy_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "ipc/ipc_test_sink.h" 12 #include "ipc/ipc_test_sink.h"
13 #include "ppapi/c/pp_instance.h" 13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/proxy/host_dispatcher.h" 14 #include "ppapi/proxy/host_dispatcher.h"
15 #include "ppapi/proxy/plugin_dispatcher.h" 15 #include "ppapi/proxy/plugin_dispatcher.h"
16 #include "ppapi/proxy/plugin_globals.h" 16 #include "ppapi/proxy/plugin_globals.h"
17 #include "ppapi/proxy/plugin_proxy_delegate.h" 17 #include "ppapi/proxy/plugin_proxy_delegate.h"
18 #include "ppapi/proxy/plugin_resource_tracker.h" 18 #include "ppapi/proxy/plugin_resource_tracker.h"
19 #include "ppapi/proxy/plugin_var_tracker.h" 19 #include "ppapi/proxy/plugin_var_tracker.h"
20 #include "ppapi/shared_impl/test_globals.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace ppapi { 23 namespace ppapi {
23 namespace proxy { 24 namespace proxy {
24 25
25 // Base class for plugin and host test harnesses. Tests will not use this 26 // Base class for plugin and host test harnesses. Tests will not use this
26 // directly. Instead, use the PluginProxyTest, HostProxyTest, or TwoWayTest. 27 // directly. Instead, use the PluginProxyTest, HostProxyTest, or TwoWayTest.
27 class ProxyTestHarnessBase { 28 class ProxyTestHarnessBase {
28 public: 29 public:
29 ProxyTestHarnessBase(); 30 ProxyTestHarnessBase();
30 virtual ~ProxyTestHarnessBase(); 31 virtual ~ProxyTestHarnessBase();
31 32
32 PP_Module pp_module() const { return pp_module_; } 33 PP_Module pp_module() const { return pp_module_; }
33 PP_Instance pp_instance() const { return pp_instance_; } 34 PP_Instance pp_instance() const { return pp_instance_; }
34 IPC::TestSink& sink() { return sink_; } 35 IPC::TestSink& sink() { return sink_; }
35 36
37 virtual PpapiGlobals* GetGlobals() = 0;
36 // Returns either the plugin or host dispatcher, depending on the test. 38 // Returns either the plugin or host dispatcher, depending on the test.
37 virtual Dispatcher* GetDispatcher() = 0; 39 virtual Dispatcher* GetDispatcher() = 0;
38 40
39 // Set up the harness using an IPC::TestSink to capture messages. 41 // Set up the harness using an IPC::TestSink to capture messages.
40 virtual void SetUpHarness() = 0; 42 virtual void SetUpHarness() = 0;
41 43
42 // Set up the harness using a real IPC channel. 44 // Set up the harness using a real IPC channel.
43 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, 45 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle,
44 base::MessageLoopProxy* ipc_message_loop, 46 base::MessageLoopProxy* ipc_message_loop,
45 base::WaitableEvent* shutdown_event, 47 base::WaitableEvent* shutdown_event,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 83
82 PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); } 84 PluginDispatcher* plugin_dispatcher() { return plugin_dispatcher_.get(); }
83 PluginResourceTracker& resource_tracker() { 85 PluginResourceTracker& resource_tracker() {
84 return *plugin_globals_.plugin_resource_tracker(); 86 return *plugin_globals_.plugin_resource_tracker();
85 } 87 }
86 PluginVarTracker& var_tracker() { 88 PluginVarTracker& var_tracker() {
87 return *plugin_globals_.plugin_var_tracker(); 89 return *plugin_globals_.plugin_var_tracker();
88 } 90 }
89 91
90 // ProxyTestHarnessBase implementation. 92 // ProxyTestHarnessBase implementation.
93 virtual PpapiGlobals* GetGlobals() { return &plugin_globals_; }
91 virtual Dispatcher* GetDispatcher(); 94 virtual Dispatcher* GetDispatcher();
92 virtual void SetUpHarness(); 95 virtual void SetUpHarness();
93 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, 96 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle,
94 base::MessageLoopProxy* ipc_message_loop, 97 base::MessageLoopProxy* ipc_message_loop,
95 base::WaitableEvent* shutdown_event, 98 base::WaitableEvent* shutdown_event,
96 bool is_client); 99 bool is_client);
97 virtual void TearDownHarness(); 100 virtual void TearDownHarness();
98 101
99 class PluginDelegateMock : public PluginDispatcher::PluginDelegate, 102 class PluginDelegateMock : public PluginDispatcher::PluginDelegate,
100 public PluginProxyDelegate { 103 public PluginProxyDelegate {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 private: 153 private:
151 MessageLoop message_loop_; 154 MessageLoop message_loop_;
152 }; 155 };
153 156
154 class HostProxyTestHarness : public ProxyTestHarnessBase { 157 class HostProxyTestHarness : public ProxyTestHarnessBase {
155 public: 158 public:
156 HostProxyTestHarness(); 159 HostProxyTestHarness();
157 virtual ~HostProxyTestHarness(); 160 virtual ~HostProxyTestHarness();
158 161
159 HostDispatcher* host_dispatcher() { return host_dispatcher_.get(); } 162 HostDispatcher* host_dispatcher() { return host_dispatcher_.get(); }
163 ResourceTracker& resource_tracker() {
164 return *host_globals_.GetResourceTracker();
165 }
166 VarTracker& var_tracker() {
167 return *host_globals_.GetVarTracker();
168 }
160 169
161 // ProxyTestBase implementation. 170 // ProxyTestBase implementation.
171 virtual PpapiGlobals* GetGlobals() { return &host_globals_; }
162 virtual Dispatcher* GetDispatcher(); 172 virtual Dispatcher* GetDispatcher();
163 virtual void SetUpHarness(); 173 virtual void SetUpHarness();
164 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle, 174 virtual void SetUpHarnessWithChannel(const IPC::ChannelHandle& channel_handle,
165 base::MessageLoopProxy* ipc_message_loop, 175 base::MessageLoopProxy* ipc_message_loop,
166 base::WaitableEvent* shutdown_event, 176 base::WaitableEvent* shutdown_event,
167 bool is_client); 177 bool is_client);
168 virtual void TearDownHarness(); 178 virtual void TearDownHarness();
169 179
170 class DelegateMock : public ProxyChannel::Delegate { 180 class DelegateMock : public ProxyChannel::Delegate {
171 public: 181 public:
(...skipping 12 matching lines...) Expand all
184 virtual base::WaitableEvent* GetShutdownEvent(); 194 virtual base::WaitableEvent* GetShutdownEvent();
185 195
186 private: 196 private:
187 base::MessageLoopProxy* ipc_message_loop_; // Weak 197 base::MessageLoopProxy* ipc_message_loop_; // Weak
188 base::WaitableEvent* shutdown_event_; // Weak 198 base::WaitableEvent* shutdown_event_; // Weak
189 199
190 DISALLOW_COPY_AND_ASSIGN(DelegateMock); 200 DISALLOW_COPY_AND_ASSIGN(DelegateMock);
191 }; 201 };
192 202
193 private: 203 private:
204 ppapi::TestGlobals host_globals_;
194 scoped_ptr<HostDispatcher> host_dispatcher_; 205 scoped_ptr<HostDispatcher> host_dispatcher_;
195 DelegateMock delegate_mock_; 206 DelegateMock delegate_mock_;
196 }; 207 };
197 208
198 class HostProxyTest : public HostProxyTestHarness, public testing::Test { 209 class HostProxyTest : public HostProxyTestHarness, public testing::Test {
199 public: 210 public:
200 HostProxyTest(); 211 HostProxyTest();
201 virtual ~HostProxyTest(); 212 virtual ~HostProxyTest();
202 213
203 // testing::Test implementation. 214 // testing::Test implementation.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // stopping the harnesses. 255 // stopping the harnesses.
245 ProxyTestHarnessBase* remote_harness_; 256 ProxyTestHarnessBase* remote_harness_;
246 ProxyTestHarnessBase* local_harness_; 257 ProxyTestHarnessBase* local_harness_;
247 258
248 base::WaitableEvent channel_created_; 259 base::WaitableEvent channel_created_;
249 base::WaitableEvent shutdown_event_; 260 base::WaitableEvent shutdown_event_;
250 }; 261 };
251 262
252 } // namespace proxy 263 } // namespace proxy
253 } // namespace ppapi 264 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_var_tracker.cc ('k') | ppapi/proxy/ppapi_proxy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698