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

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: jar feedback, compile errors 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 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { 1904 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) {
1904 // Set the result code set in PreMainMessageLoopRun or set above. 1905 // Set the result code set in PreMainMessageLoopRun or set above.
1905 *result_code = result_code_; 1906 *result_code = result_code_;
1906 if (!run_message_loop_) 1907 if (!run_message_loop_)
1907 return true; // Don't run the default message loop. 1908 return true; // Don't run the default message loop.
1908 1909
1909 // This should be invoked as close to the start of the browser's 1910 // This should be invoked as close to the start of the browser's
1910 // UI thread message loop as possible to get a stable measurement 1911 // UI thread message loop as possible to get a stable measurement
1911 // across versions. 1912 // across versions.
1912 RecordBrowserStartupTime(); 1913 RecordBrowserStartupTime();
1913 #if defined(USE_AURA) 1914 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
1914 MessageLoopForUI::current()->Run(); 1915 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS)
1915 #elif defined(TOOLKIT_VIEWS)
1916 views::AcceleratorHandler accelerator_handler; 1916 views::AcceleratorHandler accelerator_handler;
1917 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); 1917 base::RunLoop run_loop(&accelerator_handler);
1918 #elif defined(USE_X11) 1918 #else
1919 MessageLoopForUI::current()->RunWithDispatcher(NULL); 1919 base::RunLoop run_loop;
1920 #elif defined(OS_POSIX)
1921 MessageLoopForUI::current()->Run();
1922 #endif 1920 #endif
1921 run_loop.Run();
1923 1922
1924 return true; 1923 return true;
1925 } 1924 }
1926 1925
1927 void ChromeBrowserMainParts::PostMainMessageLoopRun() { 1926 void ChromeBrowserMainParts::PostMainMessageLoopRun() {
1928 // Start watching for jank during shutdown. It gets disarmed when 1927 // Start watching for jank during shutdown. It gets disarmed when
1929 // |shutdown_watcher_| object is destructed. 1928 // |shutdown_watcher_| object is destructed.
1930 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); 1929 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300));
1931 1930
1932 // Disarm the startup hang detector time bomb if it is still Arm'ed. 1931 // 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
2035 if (base::win::GetVersion() <= base::win::VERSION_XP) 2034 if (base::win::GetVersion() <= base::win::VERSION_XP)
2036 uma_name += "_XP"; 2035 uma_name += "_XP";
2037 2036
2038 uma_name += "_PreRead_"; 2037 uma_name += "_PreRead_";
2039 uma_name += pre_read_percentage; 2038 uma_name += pre_read_percentage;
2040 AddPreReadHistogramTime(uma_name.c_str(), time); 2039 AddPreReadHistogramTime(uma_name.c_str(), time);
2041 } 2040 }
2042 #endif 2041 #endif
2043 #endif 2042 #endif
2044 } 2043 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698