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

Side by Side Diff: chrome/common/histogram_synchronizer.cc

Issue 342068: Third patch in getting rid of caching MessageLoop pointers and always using C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « chrome/browser/worker_host/worker_service.cc ('k') | chrome/common/important_file_writer.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/common/histogram_synchronizer.h" 5 #include "chrome/common/histogram_synchronizer.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/thread.h" 9 #include "base/thread.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/chrome_thread.h"
11 #include "chrome/browser/renderer_host/render_process_host.h" 11 #include "chrome/browser/renderer_host/render_process_host.h"
12 #include "chrome/common/render_messages.h" 12 #include "chrome/common/render_messages.h"
13 13
14 using base::Time; 14 using base::Time;
15 using base::TimeDelta; 15 using base::TimeDelta;
16 using base::TimeTicks; 16 using base::TimeTicks;
17 17
18 HistogramSynchronizer::HistogramSynchronizer() 18 HistogramSynchronizer::HistogramSynchronizer()
19 : lock_(), 19 : lock_(),
20 received_all_renderer_historgrams_(&lock_), 20 received_all_renderer_historgrams_(&lock_),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 HistogramSynchronizer* current_synchronizer = 90 HistogramSynchronizer* current_synchronizer =
91 HistogramSynchronizer::CurrentSynchronizer(); 91 HistogramSynchronizer::CurrentSynchronizer();
92 92
93 if (current_synchronizer == NULL) { 93 if (current_synchronizer == NULL) {
94 // System teardown is happening. 94 // System teardown is happening.
95 callback_thread->PostTask(FROM_HERE, callback_task); 95 callback_thread->PostTask(FROM_HERE, callback_task);
96 return; 96 return;
97 } 97 }
98 98
99 // callback_task_ member can only be accessed on IO thread. 99 // callback_task_ member can only be accessed on IO thread.
100 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 100 ChromeThread::PostTask(
101 NewRunnableMethod(current_synchronizer, 101 ChromeThread::IO, FROM_HERE,
102 NewRunnableMethod(
103 current_synchronizer,
102 &HistogramSynchronizer::SetCallbackTaskToCallAfterGettingHistograms, 104 &HistogramSynchronizer::SetCallbackTaskToCallAfterGettingHistograms,
103 callback_thread, 105 callback_thread,
104 callback_task)); 106 callback_task));
105 107
106 // Tell all renderer processes to send their histograms. 108 // Tell all renderer processes to send their histograms.
107 int sequence_number = 109 int sequence_number =
108 current_synchronizer->GetNextAvaibleSequenceNumber(ASYNC_HISTOGRAMS); 110 current_synchronizer->GetNextAvaibleSequenceNumber(ASYNC_HISTOGRAMS);
109 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); 111 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
110 !it.IsAtEnd(); it.Advance()) { 112 !it.IsAtEnd(); it.Advance()) {
111 it.GetCurrentValue()->Send( 113 it.GetCurrentValue()->Send(
112 new ViewMsg_GetRendererHistograms(sequence_number)); 114 new ViewMsg_GetRendererHistograms(sequence_number));
113 current_synchronizer->IncrementPendingRenderers(ASYNC_HISTOGRAMS); 115 current_synchronizer->IncrementPendingRenderers(ASYNC_HISTOGRAMS);
114 } 116 }
115 117
116 // Post a task that would be called after waiting for wait_time. 118 // Post a task that would be called after waiting for wait_time.
117 g_browser_process->io_thread()->message_loop()->PostDelayedTask(FROM_HERE, 119 ChromeThread::PostDelayedTask(
118 NewRunnableMethod(current_synchronizer, 120 ChromeThread::IO, FROM_HERE,
121 NewRunnableMethod(
122 current_synchronizer,
119 &HistogramSynchronizer::ForceHistogramSynchronizationDoneCallback, 123 &HistogramSynchronizer::ForceHistogramSynchronizationDoneCallback,
120 sequence_number), 124 sequence_number),
121 wait_time); 125 wait_time);
122 } 126 }
123 127
124 // static 128 // static
125 void HistogramSynchronizer::DeserializeHistogramList( 129 void HistogramSynchronizer::DeserializeHistogramList(
126 int sequence_number, 130 int sequence_number,
127 const std::vector<std::string>& histograms) { 131 const std::vector<std::string>& histograms) {
128 HistogramSynchronizer* current_synchronizer = 132 HistogramSynchronizer* current_synchronizer =
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 261
258 bool HistogramSynchronizer::IsOnIoThread() { 262 bool HistogramSynchronizer::IsOnIoThread() {
259 if (io_message_loop_ == NULL) { 263 if (io_message_loop_ == NULL) {
260 io_message_loop_ = MessageLoop::current(); 264 io_message_loop_ = MessageLoop::current();
261 } 265 }
262 return (MessageLoop::current() == io_message_loop_); 266 return (MessageLoop::current() == io_message_loop_);
263 } 267 }
264 268
265 // static 269 // static
266 HistogramSynchronizer* HistogramSynchronizer::histogram_synchronizer_ = NULL; 270 HistogramSynchronizer* HistogramSynchronizer::histogram_synchronizer_ = NULL;
OLDNEW
« no previous file with comments | « chrome/browser/worker_host/worker_service.cc ('k') | chrome/common/important_file_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698