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

Side by Side Diff: net/base/test_completion_callback.h

Issue 112090: Avoiding IO completion callback during the closing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« net/base/file_stream_win.cc ('K') | « net/base/file_stream_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 NET_BASE_TEST_COMPLETION_CALLBACK_H_ 5 #ifndef NET_BASE_TEST_COMPLETION_CALLBACK_H_
6 #define NET_BASE_TEST_COMPLETION_CALLBACK_H_ 6 #define NET_BASE_TEST_COMPLETION_CALLBACK_H_
7 7
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "net/base/completion_callback.h" 9 #include "net/base/completion_callback.h"
10 10
(...skipping 20 matching lines...) Expand all
31 DCHECK(!waiting_for_result_); 31 DCHECK(!waiting_for_result_);
32 while (!have_result_) { 32 while (!have_result_) {
33 waiting_for_result_ = true; 33 waiting_for_result_ = true;
34 MessageLoop::current()->Run(); 34 MessageLoop::current()->Run();
35 waiting_for_result_ = false; 35 waiting_for_result_ = false;
36 } 36 }
37 have_result_ = false; // auto-reset for next callback 37 have_result_ = false; // auto-reset for next callback
38 return result_; 38 return result_;
39 } 39 }
40 40
41 bool have_result() const { return have_result_; }
42
41 private: 43 private:
42 virtual void RunWithParams(const Tuple1<int>& params) { 44 virtual void RunWithParams(const Tuple1<int>& params) {
43 result_ = params.a; 45 result_ = params.a;
44 have_result_ = true; 46 have_result_ = true;
45 if (waiting_for_result_) 47 if (waiting_for_result_)
46 MessageLoop::current()->Quit(); 48 MessageLoop::current()->Quit();
47 } 49 }
48 50
49 int result_; 51 int result_;
50 bool have_result_; 52 bool have_result_;
51 bool waiting_for_result_; 53 bool waiting_for_result_;
52 }; 54 };
53 55
54 #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_ 56 #endif // NET_BASE_TEST_COMPLETION_CALLBACK_H_
OLDNEW
« net/base/file_stream_win.cc ('K') | « net/base/file_stream_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698