OLD | NEW |
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 "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/common/chrome_utility_messages.h" | 9 #include "chrome/common/chrome_utility_messages.h" |
| 10 #include "chrome/grit/generated_resources.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/utility_process_host.h" | 12 #include "content/public/browser/utility_process_host.h" |
| 13 #include "ui/base/l10n/l10n_util.h" |
12 | 14 |
13 using content::BrowserThread; | 15 using content::BrowserThread; |
14 using content::UtilityProcessHost; | 16 using content::UtilityProcessHost; |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 // static, Leaky to allow access from any thread. | 20 // static, Leaky to allow access from any thread. |
19 base::LazyInstance<ImageDecoder>::Leaky g_decoder = LAZY_INSTANCE_INITIALIZER; | 21 base::LazyInstance<ImageDecoder>::Leaky g_decoder = LAZY_INSTANCE_INITIALIZER; |
20 | 22 |
21 // How long to wait after the last request has been received before ending | 23 // How long to wait after the last request has been received before ending |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 ++it; | 122 ++it; |
121 } | 123 } |
122 } | 124 } |
123 } | 125 } |
124 | 126 |
125 void ImageDecoder::StartBatchMode() { | 127 void ImageDecoder::StartBatchMode() { |
126 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 128 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
127 utility_process_host_ = | 129 utility_process_host_ = |
128 UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()) | 130 UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()) |
129 ->AsWeakPtr(); | 131 ->AsWeakPtr(); |
| 132 utility_process_host_->SetName(l10n_util::GetStringUTF16( |
| 133 IDS_UTILITY_PROCESS_IMAGE_DECODER_NAME)); |
130 if (!utility_process_host_->StartBatchMode()) { | 134 if (!utility_process_host_->StartBatchMode()) { |
131 utility_process_host_.reset(); | 135 utility_process_host_.reset(); |
132 return; | 136 return; |
133 } | 137 } |
134 batch_mode_timer_.Start( | 138 batch_mode_timer_.Start( |
135 FROM_HERE, base::TimeDelta::FromSeconds(kBatchModeTimeoutSeconds), | 139 FROM_HERE, base::TimeDelta::FromSeconds(kBatchModeTimeoutSeconds), |
136 this, &ImageDecoder::StopBatchMode); | 140 this, &ImageDecoder::StopBatchMode); |
137 } | 141 } |
138 | 142 |
139 void ImageDecoder::StopBatchMode() { | 143 void ImageDecoder::StopBatchMode() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 auto it = image_request_id_map_.find(request_id); | 189 auto it = image_request_id_map_.find(request_id); |
186 if (it != image_request_id_map_.end()) { | 190 if (it != image_request_id_map_.end()) { |
187 ImageRequest* image_request = it->second; | 191 ImageRequest* image_request = it->second; |
188 image_request->task_runner()->PostTask( | 192 image_request->task_runner()->PostTask( |
189 FROM_HERE, base::Bind(&ImageRequest::OnDecodeImageFailed, | 193 FROM_HERE, base::Bind(&ImageRequest::OnDecodeImageFailed, |
190 base::Unretained(image_request))); | 194 base::Unretained(image_request))); |
191 | 195 |
192 image_request_id_map_.erase(it); | 196 image_request_id_map_.erase(it); |
193 } | 197 } |
194 } | 198 } |
OLD | NEW |