| 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 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_ | 5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_ |
| 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_ | 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 9 #include "remoting/jingle_glue/xmpp_proxy.h" | 10 #include "remoting/jingle_glue/xmpp_proxy.h" |
| 10 | 11 |
| 12 namespace base { |
| 13 class MessageLoopProxy; |
| 14 } // namespace base |
| 15 |
| 11 namespace remoting { | 16 namespace remoting { |
| 12 | 17 |
| 13 class ChromotingScriptableObject; | 18 class ChromotingScriptableObject; |
| 14 | 19 |
| 15 class PepperXmppProxy : public XmppProxy { | 20 class PepperXmppProxy : public XmppProxy { |
| 16 public: | 21 public: |
| 17 PepperXmppProxy( | 22 PepperXmppProxy( |
| 18 base::WeakPtr<ChromotingScriptableObject> scriptable_object, | 23 base::WeakPtr<ChromotingScriptableObject> scriptable_object, |
| 19 MessageLoop* callback_message_loop); | 24 base::MessageLoopProxy* callback_message_loop); |
| 20 | 25 |
| 21 // Registered the callback class with this object. | 26 // Registered the callback class with this object. |
| 22 // | 27 // |
| 23 // - This method has subtle thread semantics! - | 28 // - This method has subtle thread semantics! - |
| 24 // | 29 // |
| 25 // It must be called on the callback thread itself. The weak pointer also | 30 // It must be called on the callback thread itself. The weak pointer also |
| 26 // must be constructed on the callback thread. That means, you cannot just | 31 // must be constructed on the callback thread. That means, you cannot just |
| 27 // create a WeakPtr on, say the pepper thread, and then pass execution of | 32 // create a WeakPtr on, say the pepper thread, and then pass execution of |
| 28 // this function callback with the weak pointer bound as a parameter. That | 33 // this function callback with the weak pointer bound as a parameter. That |
| 29 // will fail because the WeakPtr will have been created on the wrong thread. | 34 // will fail because the WeakPtr will have been created on the wrong thread. |
| 30 virtual void AttachCallback(base::WeakPtr<ResponseCallback> callback); | 35 virtual void AttachCallback(base::WeakPtr<ResponseCallback> callback); |
| 31 virtual void DetachCallback(); | 36 virtual void DetachCallback(); |
| 32 | 37 |
| 33 virtual void SendIq(const std::string& request_xml); | 38 virtual void SendIq(const std::string& request_xml); |
| 34 virtual void OnIq(const std::string& response_xml); | 39 virtual void OnIq(const std::string& response_xml); |
| 35 | 40 |
| 36 private: | 41 private: |
| 37 virtual ~PepperXmppProxy(); | 42 virtual ~PepperXmppProxy(); |
| 38 | 43 |
| 39 base::WeakPtr<ChromotingScriptableObject> scriptable_object_; | 44 base::WeakPtr<ChromotingScriptableObject> scriptable_object_; |
| 40 | 45 |
| 41 MessageLoop* callback_message_loop_; | 46 scoped_refptr<base::MessageLoopProxy> callback_message_loop_; |
| 42 | 47 |
| 43 // Must only be access on callback_message_loop_. | 48 // Must only be access on callback_message_loop_. |
| 44 base::WeakPtr<ResponseCallback> callback_; | 49 base::WeakPtr<ResponseCallback> callback_; |
| 45 | 50 |
| 46 DISALLOW_COPY_AND_ASSIGN(PepperXmppProxy); | 51 DISALLOW_COPY_AND_ASSIGN(PepperXmppProxy); |
| 47 }; | 52 }; |
| 48 | 53 |
| 49 } // namespace remoting | 54 } // namespace remoting |
| 50 | 55 |
| 51 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_ | 56 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_ |
| OLD | NEW |