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

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

Issue 2547173002: Use TaskScheduler instead of WorkerPool in debug_daemon_client.cc. (Closed)
Patch Set: may block Created 3 years, 12 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 (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 "chromeos/dbus/debug_daemon_client.h" 5 #include "chromeos/dbus/debug_daemon_client.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/bind_helpers.h" 17 #include "base/bind_helpers.h"
18 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
19 #include "base/json/json_string_value_serializer.h" 19 #include "base/json/json_string_value_serializer.h"
20 #include "base/location.h" 20 #include "base/location.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/posix/eintr_wrapper.h" 23 #include "base/posix/eintr_wrapper.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/task_runner_util.h" 25 #include "base/task_scheduler/post_task.h"
26 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
27 #include "base/threading/worker_pool.h"
28 #include "chromeos/dbus/pipe_reader.h" 27 #include "chromeos/dbus/pipe_reader.h"
29 #include "dbus/bus.h" 28 #include "dbus/bus.h"
30 #include "dbus/message.h" 29 #include "dbus/message.h"
31 #include "dbus/object_path.h" 30 #include "dbus/object_path.h"
32 #include "dbus/object_proxy.h" 31 #include "dbus/object_proxy.h"
33 32
34 namespace chromeos { 33 namespace chromeos {
35 34
36 namespace { 35 namespace {
37 36
(...skipping 10 matching lines...) Expand all
48 const scoped_refptr<base::RefCountedString>& unused_result) {} 47 const scoped_refptr<base::RefCountedString>& unused_result) {}
49 48
50 // A self-deleting object that wraps the pipe reader operations for reading the 49 // A self-deleting object that wraps the pipe reader operations for reading the
51 // big feedback logs. It will delete itself once the pipe stream has been 50 // big feedback logs. It will delete itself once the pipe stream has been
52 // terminated. Once the data has been completely read from the pipe, it invokes 51 // terminated. Once the data has been completely read from the pipe, it invokes
53 // the GetLogsCallback |callback| passing the deserialized logs data back to 52 // the GetLogsCallback |callback| passing the deserialized logs data back to
54 // the requester. 53 // the requester.
55 class PipeReaderWrapper : public base::SupportsWeakPtr<PipeReaderWrapper> { 54 class PipeReaderWrapper : public base::SupportsWeakPtr<PipeReaderWrapper> {
56 public: 55 public:
57 explicit PipeReaderWrapper(const DebugDaemonClient::GetLogsCallback& callback) 56 explicit PipeReaderWrapper(const DebugDaemonClient::GetLogsCallback& callback)
58 : task_runner_( 57 : pipe_reader_(base::CreateTaskRunnerWithTraits(
59 base::WorkerPool::GetTaskRunner(true /** tasks_are_slow */)), 58 base::TaskTraits().MayBlock().WithShutdownBehavior(
60 pipe_reader_(task_runner_, 59 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)),
61 base::Bind(&PipeReaderWrapper::OnIOComplete, AsWeakPtr())), 60 base::Bind(&PipeReaderWrapper::OnIOComplete, AsWeakPtr())),
62 callback_(callback) {} 61 callback_(callback) {}
63 62
64 base::ScopedFD Initialize() { return pipe_reader_.StartIO(); } 63 base::ScopedFD Initialize() { return pipe_reader_.StartIO(); }
65 64
66 void OnIOComplete() { 65 void OnIOComplete() {
67 std::string pipe_data; 66 std::string pipe_data;
68 pipe_reader_.GetData(&pipe_data); 67 pipe_reader_.GetData(&pipe_data);
69 JSONStringValueDeserializer json_reader(pipe_data); 68 JSONStringValueDeserializer json_reader(pipe_data);
70 69
(...skipping 15 matching lines...) Expand all
86 data[itr.key()] = value; 85 data[itr.key()] = value;
87 } 86 }
88 87
89 callback_.Run(true, data); 88 callback_.Run(true, data);
90 delete this; 89 delete this;
91 } 90 }
92 91
93 void TerminateStream() { pipe_reader_.OnDataReady(-1); } 92 void TerminateStream() { pipe_reader_.OnDataReady(-1); }
94 93
95 private: 94 private:
96 scoped_refptr<base::TaskRunner> task_runner_;
97 PipeReaderForString pipe_reader_; 95 PipeReaderForString pipe_reader_;
98 DebugDaemonClient::GetLogsCallback callback_; 96 DebugDaemonClient::GetLogsCallback callback_;
99 97
100 DISALLOW_COPY_AND_ASSIGN(PipeReaderWrapper); 98 DISALLOW_COPY_AND_ASSIGN(PipeReaderWrapper);
101 }; 99 };
102 100
103 } // namespace 101 } // namespace
104 102
105 // The DebugDaemonClient implementation used in production. 103 // The DebugDaemonClient implementation used in production.
106 class DebugDaemonClientImpl : public DebugDaemonClient { 104 class DebugDaemonClientImpl : public DebugDaemonClient {
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 DebugDaemonClient::EmptyStopAgentTracingCallback() { 757 DebugDaemonClient::EmptyStopAgentTracingCallback() {
760 return base::Bind(&EmptyStopAgentTracingCallbackBody); 758 return base::Bind(&EmptyStopAgentTracingCallbackBody);
761 } 759 }
762 760
763 // static 761 // static
764 DebugDaemonClient* DebugDaemonClient::Create() { 762 DebugDaemonClient* DebugDaemonClient::Create() {
765 return new DebugDaemonClientImpl(); 763 return new DebugDaemonClientImpl();
766 } 764 }
767 765
768 } // namespace chromeos 766 } // 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