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

Side by Side Diff: content/renderer/renderer_main.cc

Issue 12161002: MessageLoop's RUN method will pass a const ref to PendingTask when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/gpu/gpu_watchdog_thread.cc ('k') | media/audio/mac/audio_device_listener_mac.cc » ('j') | 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 "base/base_switches.h" 5 #include "base/base_switches.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/debug/debugger.h" 7 #include "base/debug/debugger.h"
8 #include "base/debug/stack_trace.h" 8 #include "base/debug/stack_trace.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/hi_res_timer_manager.h" 10 #include "base/hi_res_timer_manager.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/metrics/statistics_recorder.h" 16 #include "base/metrics/statistics_recorder.h"
17 #include "base/metrics/stats_counters.h" 17 #include "base/metrics/stats_counters.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/pending_task.h"
19 #include "base/process_util.h" 20 #include "base/process_util.h"
20 #include "base/string_util.h" 21 #include "base/string_util.h"
21 #include "base/system_monitor/system_monitor.h" 22 #include "base/system_monitor/system_monitor.h"
22 #include "base/threading/platform_thread.h" 23 #include "base/threading/platform_thread.h"
23 #include "base/time.h" 24 #include "base/time.h"
24 #include "content/common/pepper_plugin_registry.h" 25 #include "content/common/pepper_plugin_registry.h"
25 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
26 #include "content/public/common/main_function_params.h" 27 #include "content/public/common/main_function_params.h"
27 #include "content/public/renderer/content_renderer_client.h" 28 #include "content/public/renderer/content_renderer_client.h"
28 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" 29 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // This is a simplified version of the browser Jankometer, which measures 64 // This is a simplified version of the browser Jankometer, which measures
64 // the processing time of tasks on the render thread. 65 // the processing time of tasks on the render thread.
65 class RendererMessageLoopObserver : public MessageLoop::TaskObserver { 66 class RendererMessageLoopObserver : public MessageLoop::TaskObserver {
66 public: 67 public:
67 RendererMessageLoopObserver() 68 RendererMessageLoopObserver()
68 : process_times_(base::Histogram::FactoryGet( 69 : process_times_(base::Histogram::FactoryGet(
69 "Chrome.ProcMsgL RenderThread", 70 "Chrome.ProcMsgL RenderThread",
70 1, 3600000, 50, base::Histogram::kUmaTargetedHistogramFlag)) {} 71 1, 3600000, 50, base::Histogram::kUmaTargetedHistogramFlag)) {}
71 virtual ~RendererMessageLoopObserver() {} 72 virtual ~RendererMessageLoopObserver() {}
72 73
73 virtual void WillProcessTask(base::TimeTicks time_posted) { 74 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE {
74 begin_process_message_ = base::TimeTicks::Now(); 75 begin_process_message_ = base::TimeTicks::Now();
75 } 76 }
76 77
77 virtual void DidProcessTask(base::TimeTicks time_posted) { 78 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {
78 if (!begin_process_message_.is_null()) 79 if (!begin_process_message_.is_null())
79 process_times_->AddTime(base::TimeTicks::Now() - begin_process_message_); 80 process_times_->AddTime(base::TimeTicks::Now() - begin_process_message_);
80 } 81 }
81 82
82 private: 83 private:
83 base::TimeTicks begin_process_message_; 84 base::TimeTicks begin_process_message_;
84 base::HistogramBase* const process_times_; 85 base::HistogramBase* const process_times_;
85 DISALLOW_COPY_AND_ASSIGN(RendererMessageLoopObserver); 86 DISALLOW_COPY_AND_ASSIGN(RendererMessageLoopObserver);
86 }; 87 };
87 88
88 // For measuring memory usage after each task. Behind a command line flag. 89 // For measuring memory usage after each task. Behind a command line flag.
89 class MemoryObserver : public MessageLoop::TaskObserver { 90 class MemoryObserver : public MessageLoop::TaskObserver {
90 public: 91 public:
91 MemoryObserver() {} 92 MemoryObserver() {}
92 virtual ~MemoryObserver() {} 93 virtual ~MemoryObserver() {}
93 94
94 virtual void WillProcessTask(base::TimeTicks time_posted) OVERRIDE {} 95 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE {
96 }
95 97
96 virtual void DidProcessTask(base::TimeTicks time_posted) OVERRIDE { 98 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {
97 HISTOGRAM_MEMORY_KB("Memory.RendererUsed", webkit_glue::MemoryUsageKB()); 99 HISTOGRAM_MEMORY_KB("Memory.RendererUsed", webkit_glue::MemoryUsageKB());
98 } 100 }
99 private: 101 private:
100 DISALLOW_COPY_AND_ASSIGN(MemoryObserver); 102 DISALLOW_COPY_AND_ASSIGN(MemoryObserver);
101 }; 103 };
102 104
103 // mainline routine for running as the Renderer process 105 // mainline routine for running as the Renderer process
104 int RendererMain(const MainFunctionParams& parameters) { 106 int RendererMain(const MainFunctionParams& parameters) {
105 TRACE_EVENT_BEGIN_ETW("RendererMain", 0, ""); 107 TRACE_EVENT_BEGIN_ETW("RendererMain", 0, "");
106 108
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 MessageLoop::current()->Run(); 226 MessageLoop::current()->Run();
225 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); 227 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0);
226 } 228 }
227 } 229 }
228 platform.PlatformUninitialize(); 230 platform.PlatformUninitialize();
229 TRACE_EVENT_END_ETW("RendererMain", 0, ""); 231 TRACE_EVENT_END_ETW("RendererMain", 0, "");
230 return 0; 232 return 0;
231 } 233 }
232 234
233 } // namespace content 235 } // namespace content
OLDNEW
« no previous file with comments | « content/gpu/gpu_watchdog_thread.cc ('k') | media/audio/mac/audio_device_listener_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698