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

Side by Side Diff: components/feedback/tracing_manager.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 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 "components/feedback/tracing_manager.h" 5 #include "components/feedback/tracing_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h"
8 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
9 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
10 #include "components/feedback/feedback_util.h" 12 #include "components/feedback/feedback_util.h"
11 #include "content/public/browser/tracing_controller.h" 13 #include "content/public/browser/tracing_controller.h"
12 14
13 namespace { 15 namespace {
14 16
15 // Only once trace manager can exist at a time. 17 // Only once trace manager can exist at a time.
16 TracingManager* g_tracing_manager = NULL; 18 TracingManager* g_tracing_manager = NULL;
17 // Trace IDs start at 1 and increase. 19 // Trace IDs start at 1 and increase.
18 int g_next_trace_id = 1; 20 int g_next_trace_id = 1;
19 // Name of the file to store the tracing data as. 21 // Name of the file to store the tracing data as.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } else { 61 } else {
60 return false; 62 return false;
61 } 63 }
62 } else { 64 } else {
63 std::map<int, scoped_refptr<base::RefCountedString> >::iterator data = 65 std::map<int, scoped_refptr<base::RefCountedString> >::iterator data =
64 trace_data_.find(id); 66 trace_data_.find(id);
65 if (data == trace_data_.end()) 67 if (data == trace_data_.end())
66 return false; 68 return false;
67 69
68 // Always return the data asychronously, so the behavior is consistant. 70 // Always return the data asychronously, so the behavior is consistant.
69 base::MessageLoopProxy::current()->PostTask( 71 base::ThreadTaskRunnerHandle::Get()->PostTask(
70 FROM_HERE, 72 FROM_HERE, base::Bind(callback, data->second));
71 base::Bind(callback, data->second));
72 return true; 73 return true;
73 } 74 }
74 } 75 }
75 76
76 void TracingManager::DiscardTraceData(int id) { 77 void TracingManager::DiscardTraceData(int id) {
77 trace_data_.erase(id); 78 trace_data_.erase(id);
78 79
79 // If the trace is discarded before it is complete, clean up the accumulators. 80 // If the trace is discarded before it is complete, clean up the accumulators.
80 if (id == current_trace_id_) { 81 if (id == current_trace_id_) {
81 current_trace_id_ = 0; 82 current_trace_id_ = 0;
(...skipping 28 matching lines...) Expand all
110 111
111 if (!trace_callback_.is_null()) { 112 if (!trace_callback_.is_null()) {
112 trace_callback_.Run(output); 113 trace_callback_.Run(output);
113 trace_callback_.Reset(); 114 trace_callback_.Reset();
114 } 115 }
115 116
116 current_trace_id_ = 0; 117 current_trace_id_ = 0;
117 118
118 // Tracing has to be restarted asynchronous, so the TracingController can 119 // Tracing has to be restarted asynchronous, so the TracingController can
119 // clean up. 120 // clean up.
120 base::MessageLoopProxy::current()->PostTask( 121 base::ThreadTaskRunnerHandle::Get()->PostTask(
121 FROM_HERE, 122 FROM_HERE, base::Bind(&TracingManager::StartTracing,
122 base::Bind(&TracingManager::StartTracing, 123 weak_ptr_factory_.GetWeakPtr()));
123 weak_ptr_factory_.GetWeakPtr()));
124 } 124 }
125 125
126 // static 126 // static
127 scoped_ptr<TracingManager> TracingManager::Create() { 127 scoped_ptr<TracingManager> TracingManager::Create() {
128 if (g_tracing_manager) 128 if (g_tracing_manager)
129 return scoped_ptr<TracingManager>(); 129 return scoped_ptr<TracingManager>();
130 return scoped_ptr<TracingManager>(new TracingManager()); 130 return scoped_ptr<TracingManager>(new TracingManager());
131 } 131 }
132 132
133 TracingManager* TracingManager::Get() { 133 TracingManager* TracingManager::Get() {
134 return g_tracing_manager; 134 return g_tracing_manager;
135 } 135 }
OLDNEW
« no previous file with comments | « components/enhanced_bookmarks/enhanced_bookmark_model.cc ('k') | components/gcm_driver/fake_gcm_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698