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

Side by Side Diff: chromeos/dbus/lorgnette_manager_client.cc

Issue 2677353002: Use TaskScheduler instead of WorkerPool in lorgnette_manager_client.cc. (Closed)
Patch Set: remove unused variable Created 3 years, 10 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 | 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 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 "chromeos/dbus/lorgnette_manager_client.h" 5 #include "chromeos/dbus/lorgnette_manager_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/files/scoped_file.h" 12 #include "base/files/scoped_file.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/task_runner_util.h" 15 #include "base/task_scheduler/post_task.h"
16 #include "base/threading/worker_pool.h"
17 #include "chromeos/dbus/pipe_reader.h" 16 #include "chromeos/dbus/pipe_reader.h"
18 #include "dbus/bus.h" 17 #include "dbus/bus.h"
19 #include "dbus/message.h" 18 #include "dbus/message.h"
20 #include "dbus/object_path.h" 19 #include "dbus/object_path.h"
21 #include "dbus/object_proxy.h" 20 #include "dbus/object_proxy.h"
22 #include "third_party/cros_system_api/dbus/service_constants.h" 21 #include "third_party/cros_system_api/dbus/service_constants.h"
23 22
24 namespace chromeos { 23 namespace chromeos {
25 24
26 // The LorgnetteManagerClient implementation used in production. 25 // The LorgnetteManagerClient implementation used in production.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 97
99 ScanToStringCompletion() {} 98 ScanToStringCompletion() {}
100 virtual ~ScanToStringCompletion() {} 99 virtual ~ScanToStringCompletion() {}
101 100
102 // Creates a file stream in |file| that will stream image data to 101 // Creates a file stream in |file| that will stream image data to
103 // a string that will be supplied to |callback|. Passes ownership 102 // a string that will be supplied to |callback|. Passes ownership
104 // of |this| to a returned callback. 103 // of |this| to a returned callback.
105 CompletionCallback Start(const ScanImageToStringCallback& callback, 104 CompletionCallback Start(const ScanImageToStringCallback& callback,
106 base::ScopedFD* fd) { 105 base::ScopedFD* fd) {
107 CHECK(!pipe_reader_.get()); 106 CHECK(!pipe_reader_.get());
108 const bool kTasksAreSlow = true; 107 pipe_reader_.reset(new chromeos::PipeReaderForString(
109 scoped_refptr<base::TaskRunner> task_runner = 108 base::CreateTaskRunnerWithTraits(
110 base::WorkerPool::GetTaskRunner(kTasksAreSlow); 109 base::TaskTraits().MayBlock().WithShutdownBehavior(
111 pipe_reader_.reset( 110 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)),
112 new chromeos::PipeReaderForString( 111 base::Bind(&ScanToStringCompletion::OnScanToStringDataCompleted,
113 task_runner, 112 base::Unretained(this))));
114 base::Bind(&ScanToStringCompletion::OnScanToStringDataCompleted,
115 base::Unretained(this))));
116 *fd = pipe_reader_->StartIO(); 113 *fd = pipe_reader_->StartIO();
117 114
118 return base::Bind(&ScanToStringCompletion::OnScanToStringCompleted, 115 return base::Bind(&ScanToStringCompletion::OnScanToStringCompleted,
119 base::Owned(this), callback); 116 base::Owned(this), callback);
120 } 117 }
121 118
122 private: 119 private:
123 // Called when a |pipe_reader_| completes reading scan data to a string. 120 // Called when a |pipe_reader_| completes reading scan data to a string.
124 void OnScanToStringDataCompleted() { 121 void OnScanToStringDataCompleted() {
125 pipe_reader_->GetData(&scanned_image_data_string_); 122 pipe_reader_->GetData(&scanned_image_data_string_);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 212
216 LorgnetteManagerClient::~LorgnetteManagerClient() { 213 LorgnetteManagerClient::~LorgnetteManagerClient() {
217 } 214 }
218 215
219 // static 216 // static
220 LorgnetteManagerClient* LorgnetteManagerClient::Create() { 217 LorgnetteManagerClient* LorgnetteManagerClient::Create() {
221 return new LorgnetteManagerClientImpl(); 218 return new LorgnetteManagerClientImpl();
222 } 219 }
223 220
224 } // namespace chromeos 221 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698