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

Side by Side Diff: net/base/test_completion_callback_unittest.cc

Issue 2283373002: Remove unneeded scoped_refptr<>::get() on method binding (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
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 // Illustrates how to use worker threads that issue completion callbacks 5 // Illustrates how to use worker threads that issue completion callbacks
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ExampleEmployer::~ExampleEmployer() { 105 ExampleEmployer::~ExampleEmployer() {
106 } 106 }
107 107
108 bool ExampleEmployer::DoSomething(const CompletionCallback& callback) { 108 bool ExampleEmployer::DoSomething(const CompletionCallback& callback) {
109 DCHECK(!request_.get()) << "already in use"; 109 DCHECK(!request_.get()) << "already in use";
110 110
111 request_ = new ExampleWorker(this, callback); 111 request_ = new ExampleWorker(this, callback);
112 112
113 // Dispatch to worker thread... 113 // Dispatch to worker thread...
114 if (!base::WorkerPool::PostTask( 114 if (!base::WorkerPool::PostTask(
115 FROM_HERE, 115 FROM_HERE, base::Bind(&ExampleWorker::DoWork, request_), true)) {
116 base::Bind(&ExampleWorker::DoWork, request_.get()),
117 true)) {
118 NOTREACHED(); 116 NOTREACHED();
119 request_ = NULL; 117 request_ = NULL;
120 return false; 118 return false;
121 } 119 }
122 120
123 return true; 121 return true;
124 } 122 }
125 123
126 } // namespace 124 } // namespace
127 125
(...skipping 19 matching lines...) Expand all
147 EXPECT_TRUE(queued); 145 EXPECT_TRUE(queued);
148 146
149 EXPECT_FALSE(did_check_result); 147 EXPECT_FALSE(did_check_result);
150 closure.WaitForResult(); 148 closure.WaitForResult();
151 EXPECT_TRUE(did_check_result); 149 EXPECT_TRUE(did_check_result);
152 } 150 }
153 151
154 // TODO: test deleting ExampleEmployer while work outstanding 152 // TODO: test deleting ExampleEmployer while work outstanding
155 153
156 } // namespace net 154 } // namespace net
OLDNEW
« no previous file with comments | « jingle/notifier/listener/non_blocking_push_client.cc ('k') | net/cookies/cookie_monster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698