Chromium Code Reviews| 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; | 24 class MessageLoop; |
| 26 | 25 |
| 27 namespace base { | 26 namespace base { |
| 28 class Thread; | 27 class Thread; |
| 29 } // namespace base | 28 } // namespace base |
| 30 | 29 |
| 31 namespace pp { | 30 namespace pp { |
| 32 class InputEvent; | 31 class InputEvent; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 // Convenience wrapper to get the ChromotingScriptableObject. | 74 // Convenience wrapper to get the ChromotingScriptableObject. |
| 76 ChromotingScriptableObject* GetScriptableObject(); | 75 ChromotingScriptableObject* GetScriptableObject(); |
| 77 | 76 |
| 78 // Called by ChromotingScriptableObject to provide username and password. | 77 // Called by ChromotingScriptableObject to provide username and password. |
| 79 void SubmitLoginInfo(const std::string& username, | 78 void SubmitLoginInfo(const std::string& username, |
| 80 const std::string& password); | 79 const std::string& password); |
| 81 | 80 |
| 82 // Called by ChromotingScriptableObject to set scale-to-fit. | 81 // Called by ChromotingScriptableObject to set scale-to-fit. |
| 83 void SetScaleToFit(bool scale_to_fit); | 82 void SetScaleToFit(bool scale_to_fit); |
| 84 | 83 |
| 85 void Log(int severity, const char* format, ...); | |
| 86 void VLog(int verboselevel, const char* format, ...); | |
| 87 | |
| 88 // Return statistics record by ChromotingClient. | 84 // Return statistics record by ChromotingClient. |
| 89 // If no connection is currently active then NULL will be returned. | 85 // If no connection is currently active then NULL will be returned. |
| 90 ChromotingStats* GetStats(); | 86 ChromotingStats* GetStats(); |
| 91 | 87 |
| 92 void ReleaseAllKeys(); | 88 void ReleaseAllKeys(); |
| 93 | 89 |
| 90 static bool LogToUI(int severity, const char* file, int line, | |
|
dmac
2011/07/21 23:37:07
add a comment to the function please?
garykac
2011/08/02 00:15:37
Done.
| |
| 91 size_t message_start, const std::string& str); | |
| 94 private: | 92 private: |
| 95 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); | 93 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); |
| 96 | 94 |
| 95 void LogToUI_CorrectThread(const std::string& message); | |
| 96 | |
| 97 bool initialized_; | 97 bool initialized_; |
| 98 | 98 |
| 99 ClientContext context_; | 99 ClientContext context_; |
| 100 scoped_ptr<protocol::ConnectionToHost> host_connection_; | 100 scoped_ptr<protocol::ConnectionToHost> host_connection_; |
| 101 scoped_ptr<PepperView> view_; | 101 scoped_ptr<PepperView> view_; |
| 102 | 102 |
| 103 // PepperViewProxy is refcounted and used to interface between chromoting | 103 // PepperViewProxy is refcounted and used to interface between chromoting |
| 104 // objects and PepperView and perform thread switching. It wraps around | 104 // objects and PepperView and perform thread switching. It wraps around |
| 105 // |view_| and receives method calls on chromoting threads. These method | 105 // |view_| and receives method calls on chromoting threads. These method |
| 106 // calls are then delegates on the pepper thread. During destruction of | 106 // calls are then delegates on the pepper thread. During destruction of |
| 107 // ChromotingInstance we need to detach PepperViewProxy from PepperView since | 107 // ChromotingInstance we need to detach PepperViewProxy from PepperView since |
| 108 // both ChromotingInstance and PepperView are destroyed and there will be | 108 // both ChromotingInstance and PepperView are destroyed and there will be |
| 109 // outstanding tasks on the pepper message loo. | 109 // outstanding tasks on the pepper message loo. |
| 110 scoped_refptr<PepperViewProxy> view_proxy_; | 110 scoped_refptr<PepperViewProxy> view_proxy_; |
| 111 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; | 111 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; |
| 112 scoped_ptr<InputHandler> input_handler_; | 112 scoped_ptr<InputHandler> input_handler_; |
| 113 scoped_ptr<ChromotingClient> client_; | 113 scoped_ptr<ChromotingClient> client_; |
| 114 | 114 |
| 115 // XmppProxy is a refcounted interface used to perform thread-switching and | 115 // XmppProxy is a refcounted interface used to perform thread-switching and |
| 116 // detaching between objects whose lifetimes are controlled by pepper, and | 116 // detaching between objects whose lifetimes are controlled by pepper, and |
| 117 // jingle_glue objects. This is used when if we start a sandboxed jingle | 117 // jingle_glue objects. This is used when if we start a sandboxed jingle |
| 118 // connection. | 118 // connection. |
| 119 scoped_refptr<PepperXmppProxy> xmpp_proxy_; | 119 scoped_refptr<PepperXmppProxy> xmpp_proxy_; |
| 120 | 120 |
| 121 PepperClientLogger logger_; | |
| 122 | |
| 123 // JavaScript interface to control this instance. | 121 // JavaScript interface to control this instance. |
| 124 // This wraps a ChromotingScriptableObject in a pp::Var. | 122 // This wraps a ChromotingScriptableObject in a pp::Var. |
| 125 pp::Var instance_object_; | 123 pp::Var instance_object_; |
| 126 | 124 |
| 127 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); | 125 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); |
| 128 }; | 126 }; |
| 129 | 127 |
| 130 } // namespace remoting | 128 } // namespace remoting |
| 131 | 129 |
| 130 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingInstance); | |
|
dmac
2011/07/21 23:37:07
are we sure about this?
garykac
2011/08/02 00:15:37
I added a thread proxy class (stolen from Sergey's
| |
| 131 | |
| 132 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ | 132 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ |
| OLD | NEW |