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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: phajdan feedback Created 8 years, 5 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
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/chrome_browser_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/trace_event.h" 14 #include "base/debug/trace_event.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/metrics/field_trial.h" 17 #include "base/metrics/field_trial.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/process_info.h" 20 #include "base/process_info.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/run_loop.h"
22 #include "base/string_number_conversions.h" 23 #include "base/string_number_conversions.h"
23 #include "base/string_piece.h" 24 #include "base/string_piece.h"
24 #include "base/string_split.h" 25 #include "base/string_split.h"
25 #include "base/string_util.h" 26 #include "base/string_util.h"
26 #include "base/stringprintf.h" 27 #include "base/stringprintf.h"
27 #include "base/sys_string_conversions.h" 28 #include "base/sys_string_conversions.h"
28 #include "base/threading/platform_thread.h" 29 #include "base/threading/platform_thread.h"
29 #include "base/time.h" 30 #include "base/time.h"
30 #include "base/utf_string_conversions.h" 31 #include "base/utf_string_conversions.h"
31 #include "base/values.h" 32 #include "base/values.h"
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { 1894 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) {
1894 // Set the result code set in PreMainMessageLoopRun or set above. 1895 // Set the result code set in PreMainMessageLoopRun or set above.
1895 *result_code = result_code_; 1896 *result_code = result_code_;
1896 if (!run_message_loop_) 1897 if (!run_message_loop_)
1897 return true; // Don't run the default message loop. 1898 return true; // Don't run the default message loop.
1898 1899
1899 // This should be invoked as close to the start of the browser's 1900 // This should be invoked as close to the start of the browser's
1900 // UI thread message loop as possible to get a stable measurement 1901 // UI thread message loop as possible to get a stable measurement
1901 // across versions. 1902 // across versions.
1902 RecordBrowserStartupTime(); 1903 RecordBrowserStartupTime();
1903 #if defined(USE_AURA) 1904 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
1904 MessageLoopForUI::current()->Run(); 1905 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS)
1905 #elif defined(TOOLKIT_VIEWS)
1906 views::AcceleratorHandler accelerator_handler; 1906 views::AcceleratorHandler accelerator_handler;
1907 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); 1907 base::RunLoop run_loop(&accelerator_handler);
1908 #elif defined(USE_X11) 1908 #else
1909 MessageLoopForUI::current()->RunWithDispatcher(NULL); 1909 base::RunLoop run_loop;
1910 #elif defined(OS_POSIX)
1911 MessageLoopForUI::current()->Run();
1912 #endif 1910 #endif
1911 run_loop.Run();
1913 1912
1914 return true; 1913 return true;
1915 } 1914 }
1916 1915
1917 void ChromeBrowserMainParts::PostMainMessageLoopRun() { 1916 void ChromeBrowserMainParts::PostMainMessageLoopRun() {
1918 // Start watching for jank during shutdown. It gets disarmed when 1917 // Start watching for jank during shutdown. It gets disarmed when
1919 // |shutdown_watcher_| object is destructed. 1918 // |shutdown_watcher_| object is destructed.
1920 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); 1919 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300));
1921 1920
1922 // Disarm the startup hang detector time bomb if it is still Arm'ed. 1921 // Disarm the startup hang detector time bomb if it is still Arm'ed.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 if (base::win::GetVersion() <= base::win::VERSION_XP) 2024 if (base::win::GetVersion() <= base::win::VERSION_XP)
2026 uma_name += "_XP"; 2025 uma_name += "_XP";
2027 2026
2028 uma_name += "_PreRead_"; 2027 uma_name += "_PreRead_";
2029 uma_name += pre_read_percentage; 2028 uma_name += pre_read_percentage;
2030 AddPreReadHistogramTime(uma_name.c_str(), time); 2029 AddPreReadHistogramTime(uma_name.c_str(), time);
2031 } 2030 }
2032 #endif 2031 #endif
2033 #endif 2032 #endif
2034 } 2033 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_win.cc ('k') | chrome/browser/referrer_policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698