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

Side by Side Diff: chrome/browser/image_decoder.cc

Issue 1129653002: Wait for pending requests to finish in ImageDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove freeze test Created 5 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/image_decoder_browsertest.cc » ('j') | 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 "chrome/browser/image_decoder.h" 5 #include "chrome/browser/image_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/common/chrome_utility_messages.h" 10 #include "chrome/common/chrome_utility_messages.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 utility_process_host_->SetName(l10n_util::GetStringUTF16( 167 utility_process_host_->SetName(l10n_util::GetStringUTF16(
168 IDS_UTILITY_PROCESS_IMAGE_DECODER_NAME)); 168 IDS_UTILITY_PROCESS_IMAGE_DECODER_NAME));
169 if (!utility_process_host_->StartBatchMode()) { 169 if (!utility_process_host_->StartBatchMode()) {
170 utility_process_host_.reset(); 170 utility_process_host_.reset();
171 return; 171 return;
172 } 172 }
173 } 173 }
174 174
175 void ImageDecoder::StopBatchMode() { 175 void ImageDecoder::StopBatchMode() {
176 DCHECK_CURRENTLY_ON(BrowserThread::IO); 176 DCHECK_CURRENTLY_ON(BrowserThread::IO);
177 {
178 // Check for outstanding requests and wait for them to finish.
179 base::AutoLock lock(map_lock_);
180 if (!image_request_id_map_.empty()) {
181 batch_mode_timer_->Reset();
182 return;
183 }
184 }
185
177 if (utility_process_host_) { 186 if (utility_process_host_) {
178 utility_process_host_->EndBatchMode(); 187 utility_process_host_->EndBatchMode();
179 utility_process_host_.reset(); 188 utility_process_host_.reset();
180 } 189 }
181
182 // There could be outstanding request that are taking too long. Fail these so
183 // that there aren't any dangling requests.
184 FailAllRequests();
185 } 190 }
186 191
187 void ImageDecoder::FailAllRequests() { 192 void ImageDecoder::FailAllRequests() {
188 RequestMap requests; 193 RequestMap requests;
189 { 194 {
190 base::AutoLock lock(map_lock_); 195 base::AutoLock lock(map_lock_);
191 requests = image_request_id_map_; 196 requests = image_request_id_map_;
192 } 197 }
193 198
194 // Since |OnProcessCrashed| and |OnProcessLaunchFailed| are run asynchronously 199 // Since |OnProcessCrashed| and |OnProcessLaunchFailed| are run asynchronously
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 auto it = image_request_id_map_.find(request_id); 283 auto it = image_request_id_map_.find(request_id);
279 if (it == image_request_id_map_.end()) 284 if (it == image_request_id_map_.end())
280 return; 285 return;
281 image_request = it->second; 286 image_request = it->second;
282 image_request_id_map_.erase(it); 287 image_request_id_map_.erase(it);
283 } 288 }
284 289
285 DCHECK(image_request->task_runner()->RunsTasksOnCurrentThread()); 290 DCHECK(image_request->task_runner()->RunsTasksOnCurrentThread());
286 image_request->OnDecodeImageFailed(); 291 image_request->OnDecodeImageFailed();
287 } 292 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/image_decoder_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698