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