OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // TODO(ajwong): We need to come up with a better description of the |
| 6 // responsibilities for each thread. |
| 7 |
5 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ | 8 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ |
6 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ | 9 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ |
7 | 10 |
8 #include <string> | 11 #include <string> |
9 | 12 |
10 #include "base/at_exit.h" | 13 #include "base/at_exit.h" |
11 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
12 #include "remoting/client/host_connection.h" | 15 #include "remoting/client/host_connection.h" |
13 #include "testing/gtest/include/gtest/gtest_prod.h" | 16 #include "testing/gtest/include/gtest/gtest_prod.h" |
14 #include "third_party/ppapi/c/pp_event.h" | 17 #include "third_party/ppapi/c/pp_event.h" |
15 #include "third_party/ppapi/c/pp_instance.h" | 18 #include "third_party/ppapi/c/pp_instance.h" |
16 #include "third_party/ppapi/c/pp_rect.h" | 19 #include "third_party/ppapi/c/pp_rect.h" |
17 #include "third_party/ppapi/c/pp_resource.h" | 20 #include "third_party/ppapi/c/pp_resource.h" |
18 #include "third_party/ppapi/c/ppb_instance.h" | 21 #include "third_party/ppapi/cpp/instance.h" |
| 22 #include "third_party/ppapi/cpp/device_context_2d.h" |
| 23 |
| 24 class MessageLoop; |
19 | 25 |
20 namespace base { | 26 namespace base { |
21 class Thread; | 27 class Thread; |
22 } // namespace base | 28 } // namespace base |
23 | 29 |
| 30 namespace pp { |
| 31 class Module; |
| 32 } // namespace pp |
| 33 |
24 namespace remoting { | 34 namespace remoting { |
25 | 35 |
26 class ChromotingClient; | 36 class ChromotingClient; |
27 class HostConnection; | 37 class HostConnection; |
28 class JingleThread; | 38 class JingleThread; |
29 class PepperView; | 39 class PepperView; |
30 | 40 |
31 class ChromotingClient; | 41 class ChromotingPlugin : public pp::Instance { |
32 | |
33 class ChromotingPlugin { | |
34 public: | 42 public: |
35 // The mimetype for which this plugin is registered. | 43 // The mimetype for which this plugin is registered. |
36 // | |
37 // TODO(ajwong): Mimetype doesn't really make sense for us as the trigger | |
38 // point. I think we should handle a special protocol (eg., chromotocol://) | |
39 static const char *kMimeType; | 44 static const char *kMimeType; |
40 | 45 |
41 ChromotingPlugin(PP_Instance instance, const PPB_Instance* instance_funcs); | 46 ChromotingPlugin(PP_Instance instance); |
42 virtual ~ChromotingPlugin(); | 47 virtual ~ChromotingPlugin(); |
43 | 48 |
44 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); | 49 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); |
45 virtual bool HandleEvent(const PP_Event& event); | 50 virtual bool HandleEvent(const PP_Event& event); |
46 virtual void ViewChanged(const PP_Rect& position, const PP_Rect& clip); | 51 virtual void ViewChanged(const PP_Rect& position, const PP_Rect& clip); |
47 | 52 |
| 53 virtual bool CurrentlyOnPluginThread() const; |
| 54 |
48 private: | 55 private: |
49 FRIEND_TEST(ChromotingPluginTest, ParseUrl); | 56 FRIEND_TEST(ChromotingPluginTest, ParseUrl); |
50 FRIEND_TEST(ChromotingPluginTest, TestCaseSetup); | 57 FRIEND_TEST(ChromotingPluginTest, TestCaseSetup); |
51 | 58 |
52 static bool ParseUrl(const std::string& url, | 59 static bool ParseUrl(const std::string& url, |
53 std::string* user_id, | 60 std::string* user_id, |
54 std::string* auth_token, | 61 std::string* auth_token, |
55 std::string* host_jid); | 62 std::string* host_jid); |
56 | 63 |
57 // Size of the plugin window. | 64 // Since we're an internal plugin, we can just grab the message loop during |
58 int width_; | 65 // init to figure out which thread we're on. This should only be used to |
59 int height_; | 66 // sanity check which thread we're executing on. Do not post task here! |
60 | 67 // Instead, use PPB_Core:CallOnMainThread() in the pepper api. |
61 PP_Resource drawing_context_; | 68 // |
62 | 69 // TODO(ajwong): Think if there is a better way to safeguard this. |
63 PP_Instance pp_instance_; | 70 MessageLoop* pepper_main_loop_dont_post_to_me_; |
64 const PPB_Instance* ppb_instance_funcs_; | |
65 | 71 |
66 scoped_ptr<base::Thread> main_thread_; | 72 scoped_ptr<base::Thread> main_thread_; |
67 scoped_ptr<JingleThread> network_thread_; | 73 scoped_ptr<JingleThread> network_thread_; |
68 | 74 |
69 scoped_ptr<HostConnection> host_connection_; | 75 scoped_ptr<HostConnection> host_connection_; |
70 scoped_ptr<PepperView> view_; | 76 scoped_ptr<PepperView> view_; |
71 scoped_ptr<ChromotingClient> client_; | 77 scoped_ptr<ChromotingClient> client_; |
72 | 78 |
73 DISALLOW_COPY_AND_ASSIGN(ChromotingPlugin); | 79 DISALLOW_COPY_AND_ASSIGN(ChromotingPlugin); |
74 }; | 80 }; |
75 | 81 |
76 } // namespace remoting | 82 } // namespace remoting |
77 | 83 |
78 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ | 84 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ |
OLD | NEW |