Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: remoting/client/plugin/pepper_xmpp_proxy.h

Issue 10454018: MessageLoopProxy cleanups in remoting client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "remoting/jingle_glue/xmpp_proxy.h" 11 #include "remoting/jingle_glue/xmpp_proxy.h"
12 12
13 namespace base { 13 namespace base {
14 class MessageLoopProxy; 14 class SingleThreadTaskRunner;
15 } // namespace base 15 } // namespace base
16 16
17 namespace remoting { 17 namespace remoting {
18 18
19 class PepperXmppProxy : public XmppProxy { 19 class PepperXmppProxy : public XmppProxy {
20 public: 20 public:
21 typedef base::Callback<void(const std::string&)> SendIqCallback; 21 typedef base::Callback<void(const std::string&)> SendIqCallback;
22 22
23 // |plugin_task_runner| is the thread on which |send_iq_callback| is
24 // called. Normally the callback will call JavaScript, so this has
25 // to be the task runner that corresponds to the plugin
26 // thread. |callback_task_runner| is used to call the callback
27 // attacked with AttachCallback().
Wez 2012/06/11 22:32:44 nit: atacked -> registered
Sergey Ulanov 2012/06/11 23:35:56 Done.
23 PepperXmppProxy( 28 PepperXmppProxy(
24 const SendIqCallback& send_iq_callback, 29 const SendIqCallback& send_iq_callback,
25 base::MessageLoopProxy* plugin_message_loop, 30 base::SingleThreadTaskRunner* plugin_task_runner,
26 base::MessageLoopProxy* callback_message_loop); 31 base::SingleThreadTaskRunner* callback_task_runner);
27 32
28 // Registered the callback class with this object. 33 // Registered the callback class with this object.
29 // 34 //
30 // - This method has subtle thread semantics! - 35 // - This method has subtle thread semantics! -
31 // 36 //
32 // It must be called on the callback thread itself. The weak pointer also 37 // It must be called on the callback thread itself. The weak pointer also
33 // must be constructed on the callback thread. That means, you cannot just 38 // must be constructed on the callback thread. That means, you cannot just
34 // create a WeakPtr on, say the pepper thread, and then pass execution of 39 // create a WeakPtr on, say the pepper thread, and then pass execution of
35 // this function callback with the weak pointer bound as a parameter. That 40 // this function callback with the weak pointer bound as a parameter. That
36 // will fail because the WeakPtr will have been created on the wrong thread. 41 // will fail because the WeakPtr will have been created on the wrong thread.
37 virtual void AttachCallback( 42 virtual void AttachCallback(
38 base::WeakPtr<ResponseCallback> callback) OVERRIDE; 43 base::WeakPtr<ResponseCallback> callback) OVERRIDE;
39 virtual void DetachCallback() OVERRIDE; 44 virtual void DetachCallback() OVERRIDE;
40 45
41 virtual void SendIq(const std::string& request_xml) OVERRIDE; 46 virtual void SendIq(const std::string& request_xml) OVERRIDE;
42 virtual void OnIq(const std::string& response_xml); 47 virtual void OnIq(const std::string& response_xml);
43 48
44 private: 49 private:
45 virtual ~PepperXmppProxy(); 50 virtual ~PepperXmppProxy();
46 51
47 SendIqCallback send_iq_callback_; 52 SendIqCallback send_iq_callback_;
48 53
49 scoped_refptr<base::MessageLoopProxy> plugin_message_loop_; 54 scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_;
50 scoped_refptr<base::MessageLoopProxy> callback_message_loop_; 55 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_;
51 56
52 // Must only be access on callback_message_loop_. 57 // Must only be access on callback_message_loop_.
53 base::WeakPtr<ResponseCallback> callback_; 58 base::WeakPtr<ResponseCallback> callback_;
54 59
55 DISALLOW_COPY_AND_ASSIGN(PepperXmppProxy); 60 DISALLOW_COPY_AND_ASSIGN(PepperXmppProxy);
56 }; 61 };
57 62
58 } // namespace remoting 63 } // namespace remoting
59 64
60 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_ 65 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698