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

Side by Side Diff: chrome/browser/caps/generate_state_json.cc

Issue 1143343005: chrome/browser: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/caps/generate_state_json.h" 5 #include "chrome/browser/caps/generate_state_json.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/cpu.h" 11 #include "base/cpu.h"
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/location.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "base/sys_info.h" 19 #include "base/sys_info.h"
20 #include "base/thread_task_runner_handle.h"
19 #include "base/threading/thread_restrictions.h" 21 #include "base/threading/thread_restrictions.h"
20 #include "base/time/time.h" 22 #include "base/time/time.h"
21 #include "base/values.h" 23 #include "base/values.h"
22 #include "chrome/browser/task_manager/task_manager.h" 24 #include "chrome/browser/task_manager/task_manager.h"
23 25
24 namespace { 26 namespace {
25 27
26 std::string Key(base::ProcessId pid, const char* category) { 28 std::string Key(base::ProcessId pid, const char* category) {
27 return category ? 29 return category ?
28 base::StringPrintf("process.%d.%s", pid, category) : 30 base::StringPrintf("process.%d.%s", pid, category) :
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 69
68 private: 70 private:
69 friend class base::RefCountedThreadSafe<TaskManagerDataDumper>; 71 friend class base::RefCountedThreadSafe<TaskManagerDataDumper>;
70 ~TaskManagerDataDumper() { 72 ~TaskManagerDataDumper() {
71 } 73 }
72 74
73 void OnDataReady() { 75 void OnDataReady() {
74 // Some data (for example V8 memory) has not yet arrived, so we wait. 76 // Some data (for example V8 memory) has not yet arrived, so we wait.
75 // TODO(cpu): Figure out how to make this reliable. 77 // TODO(cpu): Figure out how to make this reliable.
76 static base::TimeDelta delay = base::TimeDelta::FromMilliseconds(250); 78 static base::TimeDelta delay = base::TimeDelta::FromMilliseconds(250);
77 base::MessageLoop::current()->PostDelayedTask( 79 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
78 FROM_HERE, 80 FROM_HERE, base::Bind(&TaskManagerDataDumper::OnDataReadyDelayed, this),
79 base::Bind(&TaskManagerDataDumper::OnDataReadyDelayed, this),
80 delay); 81 delay);
81 } 82 }
82 83
83 void OnDataReadyDelayed() { 84 void OnDataReadyDelayed() {
84 model_->StopListening(); 85 model_->StopListening();
85 // Task manager finally computed (most) values. Lets generate the JSON 86 // Task manager finally computed (most) values. Lets generate the JSON
86 // data and send it over the pipe. 87 // data and send it over the pipe.
87 base::DictionaryValue dict; 88 base::DictionaryValue dict;
88 GatherComputerValues(&dict); 89 GatherComputerValues(&dict);
89 GatherChromeValues(&dict); 90 GatherChromeValues(&dict);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } // namespace 196 } // namespace
196 197
197 namespace caps { 198 namespace caps {
198 199
199 void GenerateStateJSON( 200 void GenerateStateJSON(
200 scoped_refptr<TaskManagerModel> model, base::File file) { 201 scoped_refptr<TaskManagerModel> model, base::File file) {
201 new TaskManagerDataDumper(model, file.Pass()); 202 new TaskManagerDataDumper(model, file.Pass());
202 } 203 }
203 204
204 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698