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

Side by Side Diff: chrome/browser/metrics/perf/perf_output.h

Issue 2081153002: No dbus::FileDescriptor in DebugDaemonClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_METRICS_PERF_PERF_OUTPUT_H_ 5 #ifndef CHROME_BROWSER_METRICS_PERF_PERF_OUTPUT_H_
6 #define CHROME_BROWSER_METRICS_PERF_PERF_OUTPUT_H_ 6 #define CHROME_BROWSER_METRICS_PERF_PERF_OUTPUT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chromeos/dbus/pipe_reader.h" 16 #include "chromeos/dbus/pipe_reader.h"
17 #include "dbus/file_descriptor.h"
18 17
19 // Class for handling getting output from perf over DBus. Manages the 18 // Class for handling getting output from perf over DBus. Manages the
20 // asynchronous DBus call and retrieving data from quipper over a pipe. 19 // asynchronous DBus call and retrieving data from quipper over a pipe.
21 class PerfOutputCall { 20 class PerfOutputCall {
22 public: 21 public:
23 // Called once GetPerfOutput() is complete, or an error occurred. 22 // Called once GetPerfOutput() is complete, or an error occurred.
24 // The callback may delete this object. 23 // The callback may delete this object.
25 // The argument is one of: 24 // The argument is one of:
26 // - Output from "perf record", in PerfDataProto format, OR 25 // - Output from "perf record", in PerfDataProto format, OR
27 // - Output from "perf stat", in PerfStatProto format, OR 26 // - Output from "perf stat", in PerfStatProto format, OR
28 // - The empty string if there was an error. 27 // - The empty string if there was an error.
29 using DoneCallback = base::Callback<void(const std::string& perf_stdout)>; 28 using DoneCallback = base::Callback<void(const std::string& perf_stdout)>;
30 29
31 PerfOutputCall(scoped_refptr<base::TaskRunner> blocking_task_runner, 30 PerfOutputCall(scoped_refptr<base::TaskRunner> blocking_task_runner,
32 base::TimeDelta duration, 31 base::TimeDelta duration,
33 const std::vector<std::string>& perf_args, 32 const std::vector<std::string>& perf_args,
34 const DoneCallback& callback); 33 const DoneCallback& callback);
35 ~PerfOutputCall(); 34 ~PerfOutputCall();
36 35
37 private: 36 private:
38 // Internal callbacks. 37 // Internal callbacks.
39 void OnFileDescriptorCreated(dbus::ScopedFileDescriptor file_descriptor);
40 void OnIOComplete(); 38 void OnIOComplete();
41 void OnGetPerfOutputError(const std::string& error_name, 39 void OnGetPerfOutputError(const std::string& error_name,
42 const std::string& error_message); 40 const std::string& error_message);
43 41
44 // Used to run IO tasks. 42 // Used to run IO tasks.
45 scoped_refptr<base::TaskRunner> blocking_task_runner_; 43 scoped_refptr<base::TaskRunner> blocking_task_runner_;
46 // Used to capture perf data written to a pipe. 44 // Used to capture perf data written to a pipe.
47 std::unique_ptr<chromeos::PipeReaderForString> perf_data_pipe_reader_; 45 std::unique_ptr<chromeos::PipeReaderForString> perf_data_pipe_reader_;
48 46
49 // Saved arguments. 47 // Saved arguments.
50 base::TimeDelta duration_; 48 base::TimeDelta duration_;
51 std::vector<std::string> perf_args_; 49 std::vector<std::string> perf_args_;
52 DoneCallback done_callback_; 50 DoneCallback done_callback_;
53 51
54 base::ThreadChecker thread_checker_; 52 base::ThreadChecker thread_checker_;
55 53
56 // To pass around the "this" pointer across threads safely. 54 // To pass around the "this" pointer across threads safely.
57 base::WeakPtrFactory<PerfOutputCall> weak_factory_; 55 base::WeakPtrFactory<PerfOutputCall> weak_factory_;
58 56
59 DISALLOW_COPY_AND_ASSIGN(PerfOutputCall); 57 DISALLOW_COPY_AND_ASSIGN(PerfOutputCall);
60 }; 58 };
61 59
62 #endif // CHROME_BROWSER_METRICS_PERF_PERF_OUTPUT_H_ 60 #endif // CHROME_BROWSER_METRICS_PERF_PERF_OUTPUT_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc ('k') | chrome/browser/metrics/perf/perf_output.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698