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

Side by Side Diff: chrome/browser/service_process/service_process_control.cc

Issue 595673003: Revert of Temporary allocation of 20Mb before and after call to ServiceProcessControl::GetHistograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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 "chrome/browser/service_process/service_process_control.h" 5 #include "chrome/browser/service_process/service_process_control.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/metrics/histogram_base.h" 11 #include "base/metrics/histogram_base.h"
12 #include "base/metrics/histogram_delta_serialization.h" 12 #include "base/metrics/histogram_delta_serialization.h"
13 #include "base/process/kill.h" 13 #include "base/process/kill.h"
14 #include "base/process/launch.h" 14 #include "base/process/launch.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/upgrade_detector.h" 20 #include "chrome/browser/upgrade_detector.h"
21 #include "chrome/common/service_messages.h" 21 #include "chrome/common/service_messages.h"
22 #include "chrome/common/service_process_util.h" 22 #include "chrome/common/service_process_util.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 25
26 using content::BrowserThread; 26 using content::BrowserThread;
27 27
28 namespace {
29
30 // Test: On Mac, launchd_msg_send tries to allocate a 10MB buffer, but doesn't
31 // handle errors and makes ugly crash dumps when close to OOM.
32 // TODO(vitalybuka): Remove after few Canary builds.
33 // See http://crbug.com/406227
34 void AllocDebugTest() {
35 #if defined(OS_MACOSX)
36 void* buffer = malloc(20 * 1024 * 1024);
37 CHECK(buffer);
38 free(buffer);
39 #endif // OS_MACOSX
40 }
41
42 } // namespace
43
44 // ServiceProcessControl implementation. 28 // ServiceProcessControl implementation.
45 ServiceProcessControl::ServiceProcessControl() { 29 ServiceProcessControl::ServiceProcessControl() {
46 } 30 }
47 31
48 ServiceProcessControl::~ServiceProcessControl() { 32 ServiceProcessControl::~ServiceProcessControl() {
49 } 33 }
50 34
51 void ServiceProcessControl::ConnectInternal() { 35 void ServiceProcessControl::ConnectInternal() {
52 // If the channel has already been established then we run the task 36 // If the channel has already been established then we run the task
53 // and return. 37 // and return.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 const std::vector<std::string>& pickled_histograms) { 216 const std::vector<std::string>& pickled_histograms) {
233 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", 217 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents",
234 SERVICE_EVENT_HISTOGRAMS_REPLY, SERVICE_EVENT_MAX); 218 SERVICE_EVENT_HISTOGRAMS_REPLY, SERVICE_EVENT_MAX);
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 219 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
236 base::HistogramDeltaSerialization::DeserializeAndAddSamples( 220 base::HistogramDeltaSerialization::DeserializeAndAddSamples(
237 pickled_histograms); 221 pickled_histograms);
238 RunHistogramsCallback(); 222 RunHistogramsCallback();
239 } 223 }
240 224
241 void ServiceProcessControl::RunHistogramsCallback() { 225 void ServiceProcessControl::RunHistogramsCallback() {
242 AllocDebugTest();
243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
244 if (!histograms_callback_.is_null()) { 227 if (!histograms_callback_.is_null()) {
245 histograms_callback_.Run(); 228 histograms_callback_.Run();
246 histograms_callback_.Reset(); 229 histograms_callback_.Reset();
247 } 230 }
248 histograms_timeout_callback_.Cancel(); 231 histograms_timeout_callback_.Cancel();
249 } 232 }
250 233
251 void ServiceProcessControl::OnPrinters( 234 void ServiceProcessControl::OnPrinters(
252 const std::vector<std::string>& printers) { 235 const std::vector<std::string>& printers) {
(...skipping 16 matching lines...) Expand all
269 SERVICE_EVENT_INFO_REQUEST, SERVICE_EVENT_MAX); 252 SERVICE_EVENT_INFO_REQUEST, SERVICE_EVENT_MAX);
270 if (!Send(new ServiceMsg_GetCloudPrintProxyInfo())) 253 if (!Send(new ServiceMsg_GetCloudPrintProxyInfo()))
271 return false; 254 return false;
272 cloud_print_info_callback_ = cloud_print_info_callback; 255 cloud_print_info_callback_ = cloud_print_info_callback;
273 return true; 256 return true;
274 } 257 }
275 258
276 bool ServiceProcessControl::GetHistograms( 259 bool ServiceProcessControl::GetHistograms(
277 const base::Closure& histograms_callback, 260 const base::Closure& histograms_callback,
278 const base::TimeDelta& timeout) { 261 const base::TimeDelta& timeout) {
279 AllocDebugTest();
280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
281 DCHECK(!histograms_callback.is_null()); 263 DCHECK(!histograms_callback.is_null());
282 histograms_callback_.Reset(); 264 histograms_callback_.Reset();
283 265
284 // If the service process is already running then connect to it. 266 // If the service process is already running then connect to it.
285 if (!CheckServiceProcessReady()) 267 if (!CheckServiceProcessReady())
286 return false; 268 return false;
287 ConnectInternal(); 269 ConnectInternal();
288 270
289 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", 271 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents",
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (base::LaunchProcess(*cmd_line_, options, &process_handle_)) { 385 if (base::LaunchProcess(*cmd_line_, options, &process_handle_)) {
404 BrowserThread::PostTask( 386 BrowserThread::PostTask(
405 BrowserThread::IO, FROM_HERE, 387 BrowserThread::IO, FROM_HERE,
406 base::Bind(&Launcher::DoDetectLaunched, this)); 388 base::Bind(&Launcher::DoDetectLaunched, this));
407 } else { 389 } else {
408 BrowserThread::PostTask( 390 BrowserThread::PostTask(
409 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); 391 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this));
410 } 392 }
411 } 393 }
412 #endif // !OS_MACOSX 394 #endif // !OS_MACOSX
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698