diff options
author | kulkarni.a <kulkarni.a@samsung.com> | 2014-08-28 00:41:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-28 07:42:22 +0000 |
commit | cd7b446148ba6ef5874000c3679d6431b6d5588b (patch) | |
tree | 61bc4ee2c37e7bf31656e112bd1d9204f869cc98 /net/test | |
parent | a67fc9609e16eb3ce75a4a0e39f0e2622f1ba4da (diff) | |
download | chromium_src-cd7b446148ba6ef5874000c3679d6431b6d5588b.zip chromium_src-cd7b446148ba6ef5874000c3679d6431b6d5588b.tar.gz chromium_src-cd7b446148ba6ef5874000c3679d6431b6d5588b.tar.bz2 |
Declaring the weak_ptr_factory in proper order.
Cleaning up weak_ptr_factory destruction order in "src/net" module.
WeakPtrFactory should remain the last member so it'll be destroyed and
invalidate its weak pointers before any other members are destroyed.
BUG=303818
Review URL: https://codereview.chromium.org/506523002
Cr-Commit-Position: refs/heads/master@{#292344}
Diffstat (limited to 'net/test')
-rw-r--r-- | net/test/embedded_test_server/embedded_test_server.h | 4 | ||||
-rw-r--r-- | net/test/spawned_test_server/spawner_communicator.cc | 4 | ||||
-rw-r--r-- | net/test/spawned_test_server/spawner_communicator.h | 8 |
3 files changed, 8 insertions, 8 deletions
diff --git a/net/test/embedded_test_server/embedded_test_server.h b/net/test/embedded_test_server/embedded_test_server.h index 1232388..a490f25 100644 --- a/net/test/embedded_test_server/embedded_test_server.h +++ b/net/test/embedded_test_server/embedded_test_server.h @@ -186,12 +186,12 @@ class EmbeddedTestServer : public StreamListenSocket::Delegate { // Vector of registered request handlers. std::vector<HandleRequestCallback> request_handlers_; + base::ThreadChecker thread_checker_; + // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<EmbeddedTestServer> weak_factory_; - base::ThreadChecker thread_checker_; - DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); }; diff --git a/net/test/spawned_test_server/spawner_communicator.cc b/net/test/spawned_test_server/spawner_communicator.cc index d7736b8..9aadb87 100644 --- a/net/test/spawned_test_server/spawner_communicator.cc +++ b/net/test/spawned_test_server/spawner_communicator.cc @@ -103,8 +103,8 @@ SpawnerCommunicator::SpawnerCommunicator(uint16 port) event_(false, false), port_(port), next_id_(0), - weak_factory_(this), - is_running_(false) {} + is_running_(false), + weak_factory_(this) {} SpawnerCommunicator::~SpawnerCommunicator() { DCHECK(!is_running_); diff --git a/net/test/spawned_test_server/spawner_communicator.h b/net/test/spawned_test_server/spawner_communicator.h index bf426e6..b657ac3 100644 --- a/net/test/spawned_test_server/spawner_communicator.h +++ b/net/test/spawned_test_server/spawner_communicator.h @@ -130,10 +130,6 @@ class SpawnerCommunicator : public net::URLRequest::Delegate { // The next ID to use for |cur_request_| (monotonically increasing). int next_id_; - // Factory for creating the time-out task. This takes care of revoking - // outstanding tasks when |this| is deleted. - base::WeakPtrFactory<SpawnerCommunicator> weak_factory_; - // Request context used by |cur_request_|. scoped_ptr<URLRequestContext> context_; @@ -143,6 +139,10 @@ class SpawnerCommunicator : public net::URLRequest::Delegate { // Only gets/sets |is_running_| on user's thread to avoid race-condition. bool is_running_; + // Factory for creating the time-out task. This takes care of revoking + // outstanding tasks when |this| is deleted. + base::WeakPtrFactory<SpawnerCommunicator> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(SpawnerCommunicator); }; |