OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit y_client.h" | 8 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit y_client.h" |
9 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 9 #include "chrome/common/extensions/chrome_utility_extensions_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" |
12 #include "ui/base/l10n/l10n_util.h" | |
11 | 13 |
12 using content::BrowserThread; | 14 using content::BrowserThread; |
13 | 15 |
14 ImageWriterUtilityClient::ImageWriterUtilityClient() | 16 ImageWriterUtilityClient::ImageWriterUtilityClient() |
15 : message_loop_proxy_(base::MessageLoopProxy::current()) {} | 17 : message_loop_proxy_(base::MessageLoopProxy::current()) {} |
16 ImageWriterUtilityClient::~ImageWriterUtilityClient() {} | 18 ImageWriterUtilityClient::~ImageWriterUtilityClient() {} |
17 | 19 |
18 void ImageWriterUtilityClient::Write(const ProgressCallback& progress_callback, | 20 void ImageWriterUtilityClient::Write(const ProgressCallback& progress_callback, |
19 const SuccessCallback& success_callback, | 21 const SuccessCallback& success_callback, |
20 const ErrorCallback& error_callback, | 22 const ErrorCallback& error_callback, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 error_callback_ = base::Callback<void(const std::string&)>(); | 85 error_callback_ = base::Callback<void(const std::string&)>(); |
84 cancel_callback_ = base::Closure(); | 86 cancel_callback_ = base::Closure(); |
85 } | 87 } |
86 | 88 |
87 void ImageWriterUtilityClient::StartHost() { | 89 void ImageWriterUtilityClient::StartHost() { |
88 if (!utility_process_host_) { | 90 if (!utility_process_host_) { |
89 scoped_refptr<base::SequencedTaskRunner> task_runner = | 91 scoped_refptr<base::SequencedTaskRunner> task_runner = |
90 base::MessageLoop::current()->message_loop_proxy(); | 92 base::MessageLoop::current()->message_loop_proxy(); |
91 utility_process_host_ = content::UtilityProcessHost::Create( | 93 utility_process_host_ = content::UtilityProcessHost::Create( |
92 this, task_runner.get())->AsWeakPtr(); | 94 this, task_runner.get())->AsWeakPtr(); |
95 utility_process_host_->SetName(l10n_util::GetStringUTF16( | |
not at google - send to devlin
2015/04/07 16:45:39
The next round of utility processes are just going
Lei Zhang
2015/04/07 21:53:54
I was thinking about that, but I don't want to for
| |
96 IDS_UTILITY_PROCESS_IMAGE_WRITER_NAME)); | |
not at google - send to devlin
2015/04/07 16:45:39
Triaging process manager bugs filed from other lan
Lei Zhang
2015/04/07 21:53:54
The translators are going to have fun with these a
| |
93 | 97 |
94 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
95 utility_process_host_->ElevatePrivileges(); | 99 utility_process_host_->ElevatePrivileges(); |
96 #else | 100 #else |
97 utility_process_host_->DisableSandbox(); | 101 utility_process_host_->DisableSandbox(); |
98 #endif | 102 #endif |
99 utility_process_host_->StartBatchMode(); | 103 utility_process_host_->StartBatchMode(); |
100 } | 104 } |
101 } | 105 } |
102 | 106 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 base::Bind(error_callback_, message)); | 152 base::Bind(error_callback_, message)); |
149 } | 153 } |
150 } | 154 } |
151 | 155 |
152 void ImageWriterUtilityClient::OnWriteImageProgress(int64 progress) { | 156 void ImageWriterUtilityClient::OnWriteImageProgress(int64 progress) { |
153 if (!progress_callback_.is_null()) { | 157 if (!progress_callback_.is_null()) { |
154 message_loop_proxy_->PostTask(FROM_HERE, | 158 message_loop_proxy_->PostTask(FROM_HERE, |
155 base::Bind(progress_callback_, progress)); | 159 base::Bind(progress_callback_, progress)); |
156 } | 160 } |
157 } | 161 } |
OLD | NEW |