| OLD | NEW |
| 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 // 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_INSTANCE_H_ | 8 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
| 9 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ | 9 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "ppapi/c/pp_instance.h" | 15 #include "ppapi/c/pp_instance.h" |
| 16 #include "ppapi/c/pp_rect.h" | 16 #include "ppapi/c/pp_rect.h" |
| 17 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
| 18 #include "ppapi/cpp/var.h" | 18 #include "ppapi/cpp/var.h" |
| 19 #include "ppapi/cpp/private/instance_private.h" | 19 #include "ppapi/cpp/private/instance_private.h" |
| 20 #include "remoting/client/client_context.h" | 20 #include "remoting/client/client_context.h" |
| 21 #include "remoting/client/plugin/chromoting_scriptable_object.h" | 21 #include "remoting/client/plugin/chromoting_scriptable_object.h" |
| 22 #include "remoting/client/plugin/pepper_client_logger.h" | |
| 23 #include "remoting/protocol/connection_to_host.h" | 22 #include "remoting/protocol/connection_to_host.h" |
| 24 | 23 |
| 25 class MessageLoop; | |
| 26 | |
| 27 namespace base { | 24 namespace base { |
| 28 class Thread; | 25 class Thread; |
| 29 } // namespace base | 26 } // namespace base |
| 30 | 27 |
| 31 namespace pp { | 28 namespace pp { |
| 32 class InputEvent; | 29 class InputEvent; |
| 33 class Module; | 30 class Module; |
| 34 } // namespace pp | 31 } // namespace pp |
| 35 | 32 |
| 36 namespace remoting { | 33 namespace remoting { |
| 37 | 34 |
| 38 namespace protocol { | 35 namespace protocol { |
| 39 class ConnectionToHost; | 36 class ConnectionToHost; |
| 40 } // namespace protocol | 37 } // namespace protocol |
| 41 | 38 |
| 42 class ChromotingClient; | 39 class ChromotingClient; |
| 43 class ChromotingStats; | 40 class ChromotingStats; |
| 44 class ClientContext; | 41 class ClientContext; |
| 45 class InputHandler; | 42 class InputHandler; |
| 46 class JingleThread; | 43 class JingleThread; |
| 47 class PepperView; | 44 class PepperView; |
| 48 class PepperViewProxy; | 45 class PepperViewProxy; |
| 49 class RectangleUpdateDecoder; | 46 class RectangleUpdateDecoder; |
| 47 class TaskThreadProxy; |
| 50 | 48 |
| 51 struct ClientConfig; | 49 struct ClientConfig; |
| 52 | 50 |
| 53 namespace protocol { | 51 namespace protocol { |
| 54 class HostConnection; | 52 class HostConnection; |
| 55 } // namespace protocol | 53 } // namespace protocol |
| 56 | 54 |
| 57 class ChromotingInstance : public pp::InstancePrivate { | 55 class ChromotingInstance : public pp::InstancePrivate { |
| 58 public: | 56 public: |
| 59 // The mimetype for which this plugin is registered. | 57 // The mimetype for which this plugin is registered. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 75 // Convenience wrapper to get the ChromotingScriptableObject. | 73 // Convenience wrapper to get the ChromotingScriptableObject. |
| 76 ChromotingScriptableObject* GetScriptableObject(); | 74 ChromotingScriptableObject* GetScriptableObject(); |
| 77 | 75 |
| 78 // Called by ChromotingScriptableObject to provide username and password. | 76 // Called by ChromotingScriptableObject to provide username and password. |
| 79 void SubmitLoginInfo(const std::string& username, | 77 void SubmitLoginInfo(const std::string& username, |
| 80 const std::string& password); | 78 const std::string& password); |
| 81 | 79 |
| 82 // Called by ChromotingScriptableObject to set scale-to-fit. | 80 // Called by ChromotingScriptableObject to set scale-to-fit. |
| 83 void SetScaleToFit(bool scale_to_fit); | 81 void SetScaleToFit(bool scale_to_fit); |
| 84 | 82 |
| 85 void Log(int severity, const char* format, ...); | |
| 86 void VLog(int verboselevel, const char* format, ...); | |
| 87 | |
| 88 // Return statistics record by ChromotingClient. | 83 // Return statistics record by ChromotingClient. |
| 89 // If no connection is currently active then NULL will be returned. | 84 // If no connection is currently active then NULL will be returned. |
| 90 ChromotingStats* GetStats(); | 85 ChromotingStats* GetStats(); |
| 91 | 86 |
| 92 void ReleaseAllKeys(); | 87 void ReleaseAllKeys(); |
| 93 | 88 |
| 94 bool DoScaling() const { return scale_to_fit_; } | 89 bool DoScaling() const { return scale_to_fit_; } |
| 95 | 90 |
| 91 // A Log Message Handler that is called after each LOG message has been |
| 92 // processed. This must be of type LogMessageHandlerFunction defined in |
| 93 // base/logging.h. |
| 94 static bool LogToUI(int severity, const char* file, int line, |
| 95 size_t message_start, const std::string& str); |
| 96 private: | 96 private: |
| 97 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); | 97 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); |
| 98 | 98 |
| 99 void ProcessLogToUI(const std::string& message); |
| 100 |
| 99 bool initialized_; | 101 bool initialized_; |
| 100 | 102 |
| 101 ClientContext context_; | 103 ClientContext context_; |
| 102 scoped_ptr<protocol::ConnectionToHost> host_connection_; | 104 scoped_ptr<protocol::ConnectionToHost> host_connection_; |
| 103 scoped_ptr<PepperView> view_; | 105 scoped_ptr<PepperView> view_; |
| 104 | 106 |
| 105 // True if scale to fit is enabled. | 107 // True if scale to fit is enabled. |
| 106 bool scale_to_fit_; | 108 bool scale_to_fit_; |
| 107 | 109 |
| 110 // A refcounted class to perform thread-switching for logging tasks. |
| 111 scoped_refptr<TaskThreadProxy> log_proxy_; |
| 112 |
| 108 // PepperViewProxy is refcounted and used to interface between chromoting | 113 // PepperViewProxy is refcounted and used to interface between chromoting |
| 109 // objects and PepperView and perform thread switching. It wraps around | 114 // objects and PepperView and perform thread switching. It wraps around |
| 110 // |view_| and receives method calls on chromoting threads. These method | 115 // |view_| and receives method calls on chromoting threads. These method |
| 111 // calls are then delegates on the pepper thread. During destruction of | 116 // calls are then delegates on the pepper thread. During destruction of |
| 112 // ChromotingInstance we need to detach PepperViewProxy from PepperView since | 117 // ChromotingInstance we need to detach PepperViewProxy from PepperView since |
| 113 // both ChromotingInstance and PepperView are destroyed and there will be | 118 // both ChromotingInstance and PepperView are destroyed and there will be |
| 114 // outstanding tasks on the pepper message loo. | 119 // outstanding tasks on the pepper message loop. |
| 115 scoped_refptr<PepperViewProxy> view_proxy_; | 120 scoped_refptr<PepperViewProxy> view_proxy_; |
| 116 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; | 121 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; |
| 117 scoped_ptr<InputHandler> input_handler_; | 122 scoped_ptr<InputHandler> input_handler_; |
| 118 scoped_ptr<ChromotingClient> client_; | 123 scoped_ptr<ChromotingClient> client_; |
| 119 | 124 |
| 120 // XmppProxy is a refcounted interface used to perform thread-switching and | 125 // XmppProxy is a refcounted interface used to perform thread-switching and |
| 121 // detaching between objects whose lifetimes are controlled by pepper, and | 126 // detaching between objects whose lifetimes are controlled by pepper, and |
| 122 // jingle_glue objects. This is used when if we start a sandboxed jingle | 127 // jingle_glue objects. This is used when if we start a sandboxed jingle |
| 123 // connection. | 128 // connection. |
| 124 scoped_refptr<PepperXmppProxy> xmpp_proxy_; | 129 scoped_refptr<PepperXmppProxy> xmpp_proxy_; |
| 125 | 130 |
| 126 PepperClientLogger logger_; | |
| 127 | |
| 128 // JavaScript interface to control this instance. | 131 // JavaScript interface to control this instance. |
| 129 // This wraps a ChromotingScriptableObject in a pp::Var. | 132 // This wraps a ChromotingScriptableObject in a pp::Var. |
| 130 pp::Var instance_object_; | 133 pp::Var instance_object_; |
| 131 | 134 |
| 132 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); | 135 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); |
| 133 }; | 136 }; |
| 134 | 137 |
| 135 } // namespace remoting | 138 } // namespace remoting |
| 136 | 139 |
| 137 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ | 140 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
| OLD | NEW |