Index: remoting/test/test_chromoting_client.h |
diff --git a/remoting/test/test_chromoting_client.h b/remoting/test/test_chromoting_client.h |
index cb0c730b0837483ab3eb038ef100011107c3f84a..202539d7898d5cd2082655a04364ede66e68b7f7 100644 |
--- a/remoting/test/test_chromoting_client.h |
+++ b/remoting/test/test_chromoting_client.h |
@@ -9,6 +9,7 @@ |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/memory/weak_ptr.h" |
#include "base/observer_list.h" |
#include "remoting/client/chromoting_client.h" |
#include "remoting/client/client_user_interface.h" |
@@ -71,6 +72,11 @@ class TestChromotingClient : public ClientUserInterface, |
void SetConnectionToHostForTests( |
scoped_ptr<protocol::ConnectionToHost> connection_to_host); |
+ // Gets a weak pointer for this object. |
+ base::WeakPtr<TestChromotingClient> GetWeakPtr() { |
Sergey Ulanov
2015/07/23 19:36:55
I don't think you really need this - see my other
liaoyuke
2015/07/24 02:07:28
Done.
|
+ return weak_factory_.GetWeakPtr(); |
+ } |
+ |
private: |
// ClientUserInterface interface. |
void OnConnectionState(protocol::ConnectionToHost::State state, |
@@ -117,6 +123,10 @@ class TestChromotingClient : public ClientUserInterface, |
// Used to establish an XMPP connection with the google talk service. |
scoped_ptr<XmppSignalStrategy> signal_strategy_; |
+ // Used to weakly bind |this| to methods. |
+ // NOTE: Weak pointers must be invalidated before all other member variables. |
+ base::WeakPtrFactory<TestChromotingClient> weak_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(TestChromotingClient); |
}; |