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

Side by Side Diff: chrome/browser/chromeos/arc/tracing/arc_tracing_bridge.cc

Issue 2400163003: arc: enable Android tracing in verified-boot mode (Closed)
Patch Set: rebase to tot Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/chromeos/arc/tracing/arc_tracing_bridge.h" 5 #include "chrome/browser/chromeos/arc/tracing/arc_tracing_bridge.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "components/arc/arc_bridge_service.h" 10 #include "components/arc/arc_bridge_service.h"
11 #include "components/arc/arc_service_manager.h" 11 #include "components/arc/arc_service_manager.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "mojo/public/cpp/system/platform_handle.h"
13 14
14 namespace arc { 15 namespace arc {
15 16
16 namespace { 17 namespace {
17 18
18 // The prefix of the categories to be shown on the trace selection UI. 19 // The prefix of the categories to be shown on the trace selection UI.
19 // The space at the end of the string is intentional as the separator between 20 // The space at the end of the string is intentional as the separator between
20 // the prefix and the real categories. 21 // the prefix and the real categories.
21 constexpr char kCategoryPrefix[] = TRACE_DISABLED_BY_DEFAULT("android "); 22 constexpr char kCategoryPrefix[] = TRACE_DISABLED_BY_DEFAULT("android ");
22 23
(...skipping 29 matching lines...) Expand all
52 53
53 void ArcTracingBridge::OnCategoriesReady( 54 void ArcTracingBridge::OnCategoriesReady(
54 const std::vector<std::string>& categories) { 55 const std::vector<std::string>& categories) {
55 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 56 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
56 57
57 // There is no API in TraceLog to remove a category from the UI. As an 58 // There is no API in TraceLog to remove a category from the UI. As an
58 // alternative, the old category that is no longer in |categories_| will be 59 // alternative, the old category that is no longer in |categories_| will be
59 // ignored when calling |StartTracing|. 60 // ignored when calling |StartTracing|.
60 categories_.clear(); 61 categories_.clear();
61 for (const auto& category : categories) { 62 for (const auto& category : categories) {
62 categories_.push_back({category, kCategoryPrefix + category}); 63 categories_.emplace_back(Category{category, kCategoryPrefix + category});
63 // Show the category name in the selection UI. 64 // Show the category name in the selection UI.
64 base::trace_event::TraceLog::GetCategoryGroupEnabled( 65 base::trace_event::TraceLog::GetCategoryGroupEnabled(
65 categories_.back().full_name.c_str()); 66 categories_.back().full_name.c_str());
66 } 67 }
67 } 68 }
68 69
69 void ArcTracingBridge::StartTracing( 70 void ArcTracingBridge::StartTracing(
70 const base::trace_event::TraceConfig& trace_config, 71 const base::trace_event::TraceConfig& trace_config,
72 base::ScopedFD write_fd,
71 const StartTracingCallback& callback) { 73 const StartTracingCallback& callback) {
72 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 74 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
73 75
74 mojom::TracingInstance* tracing_instance = ARC_GET_INSTANCE_FOR_METHOD( 76 mojom::TracingInstance* tracing_instance = ARC_GET_INSTANCE_FOR_METHOD(
75 arc_bridge_service()->tracing(), StartTracing); 77 arc_bridge_service()->tracing(), StartTracing);
76 if (!tracing_instance) { 78 if (!tracing_instance) {
77 // Use PostTask as the convention of TracingAgent. The caller expects 79 // Use PostTask as the convention of TracingAgent. The caller expects
78 // callback to be called after this function returns. 80 // callback to be called after this function returns.
79 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 81 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
80 base::Bind(callback, false)); 82 base::Bind(callback, false));
81 return; 83 return;
82 } 84 }
83 85
84 std::vector<std::string> selected_categories; 86 std::vector<std::string> selected_categories;
85 for (const auto& category : categories_) { 87 for (const auto& category : categories_) {
86 if (trace_config.IsCategoryGroupEnabled(category.full_name)) 88 if (trace_config.IsCategoryGroupEnabled(category.full_name))
87 selected_categories.push_back(category.name); 89 selected_categories.push_back(category.name);
88 } 90 }
89 91
90 tracing_instance->StartTracing(selected_categories, callback); 92 tracing_instance->StartTracing(selected_categories,
93 mojo::WrapPlatformFile(write_fd.release()),
94 callback);
91 } 95 }
92 96
93 void ArcTracingBridge::StopTracing(const StopTracingCallback& callback) { 97 void ArcTracingBridge::StopTracing(const StopTracingCallback& callback) {
94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 98 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
95 99
96 mojom::TracingInstance* tracing_instance = 100 mojom::TracingInstance* tracing_instance =
97 ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->tracing(), StopTracing); 101 ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->tracing(), StopTracing);
98 if (!tracing_instance) { 102 if (!tracing_instance) {
99 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 103 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
100 base::Bind(callback, false)); 104 base::Bind(callback, false));
101 return; 105 return;
102 } 106 }
103 tracing_instance->StopTracing(callback); 107 tracing_instance->StopTracing(callback);
104 } 108 }
105 109
106 } // namespace arc 110 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/tracing/arc_tracing_bridge.h ('k') | components/arc/common/tracing.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698