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

Side by Side Diff: net/disk_cache/in_flight_io.cc

Issue 10151009: Disallow UI/IO thread blocking on any other thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « net/disk_cache/backend_impl.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) 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 #include "net/disk_cache/in_flight_io.h" 5 #include "net/disk_cache/in_flight_io.h"
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/threading/thread_restrictions.h"
10 11
11 namespace disk_cache { 12 namespace disk_cache {
12 13
13 BackgroundIO::BackgroundIO(InFlightIO* controller) 14 BackgroundIO::BackgroundIO(InFlightIO* controller)
14 : result_(-1), io_completed_(true, false), controller_(controller) { 15 : result_(-1), io_completed_(true, false), controller_(controller) {
15 } 16 }
16 17
17 // Runs on the primary thread. 18 // Runs on the primary thread.
18 void BackgroundIO::OnIOSignalled() { 19 void BackgroundIO::OnIOSignalled() {
19 if (controller_) 20 if (controller_)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #endif 76 #endif
76 77
77 callback_thread_->PostTask(FROM_HERE, 78 callback_thread_->PostTask(FROM_HERE,
78 base::Bind(&BackgroundIO::OnIOSignalled, 79 base::Bind(&BackgroundIO::OnIOSignalled,
79 operation)); 80 operation));
80 operation->io_completed()->Signal(); 81 operation->io_completed()->Signal();
81 } 82 }
82 83
83 // Runs on the primary thread. 84 // Runs on the primary thread.
84 void InFlightIO::InvokeCallback(BackgroundIO* operation, bool cancel_task) { 85 void InFlightIO::InvokeCallback(BackgroundIO* operation, bool cancel_task) {
85 operation->io_completed()->Wait(); 86 {
87 // http://crbug.com/74623
88 base::ThreadRestrictions::ScopedAllowWait allow_wait;
89 operation->io_completed()->Wait();
90 }
86 running_ = true; 91 running_ = true;
87 92
88 if (cancel_task) 93 if (cancel_task)
89 operation->Cancel(); 94 operation->Cancel();
90 95
91 // Make sure that we remove the operation from the list before invoking the 96 // Make sure that we remove the operation from the list before invoking the
92 // callback (so that a subsequent cancel does not invoke the callback again). 97 // callback (so that a subsequent cancel does not invoke the callback again).
93 DCHECK(io_list_.find(operation) != io_list_.end()); 98 DCHECK(io_list_.find(operation) != io_list_.end());
94 DCHECK(!operation->HasOneRef()); 99 DCHECK(!operation->HasOneRef());
95 io_list_.erase(make_scoped_refptr(operation)); 100 io_list_.erase(make_scoped_refptr(operation));
96 OnOperationComplete(operation, cancel_task); 101 OnOperationComplete(operation, cancel_task);
97 } 102 }
98 103
99 // Runs on the primary thread. 104 // Runs on the primary thread.
100 void InFlightIO::OnOperationPosted(BackgroundIO* operation) { 105 void InFlightIO::OnOperationPosted(BackgroundIO* operation) {
101 DCHECK(callback_thread_->BelongsToCurrentThread()); 106 DCHECK(callback_thread_->BelongsToCurrentThread());
102 io_list_.insert(make_scoped_refptr(operation)); 107 io_list_.insert(make_scoped_refptr(operation));
103 } 108 }
104 109
105 } // namespace disk_cache 110 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698