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

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

Issue 9667009: CommandLine Page Cycler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: PageCycler CommandLine Created 8 years, 9 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
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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "chrome/browser/metrics/field_trial_synchronizer.h" 51 #include "chrome/browser/metrics/field_trial_synchronizer.h"
52 #include "chrome/browser/metrics/histogram_synchronizer.h" 52 #include "chrome/browser/metrics/histogram_synchronizer.h"
53 #include "chrome/browser/metrics/metrics_log.h" 53 #include "chrome/browser/metrics/metrics_log.h"
54 #include "chrome/browser/metrics/metrics_service.h" 54 #include "chrome/browser/metrics/metrics_service.h"
55 #include "chrome/browser/metrics/thread_watcher.h" 55 #include "chrome/browser/metrics/thread_watcher.h"
56 #include "chrome/browser/metrics/tracking_synchronizer.h" 56 #include "chrome/browser/metrics/tracking_synchronizer.h"
57 #include "chrome/browser/nacl_host/nacl_process_host.h" 57 #include "chrome/browser/nacl_host/nacl_process_host.h"
58 #include "chrome/browser/net/chrome_net_log.h" 58 #include "chrome/browser/net/chrome_net_log.h"
59 #include "chrome/browser/net/predictor.h" 59 #include "chrome/browser/net/predictor.h"
60 #include "chrome/browser/notifications/desktop_notification_service.h" 60 #include "chrome/browser/notifications/desktop_notification_service.h"
61 #include "chrome/browser/page_cycler/page_cycler.h"
61 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 62 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
62 #include "chrome/browser/plugin_prefs.h" 63 #include "chrome/browser/plugin_prefs.h"
63 #include "chrome/browser/prefs/pref_service.h" 64 #include "chrome/browser/prefs/pref_service.h"
64 #include "chrome/browser/prefs/pref_value_store.h" 65 #include "chrome/browser/prefs/pref_value_store.h"
65 #include "chrome/browser/prefs/scoped_user_pref_update.h" 66 #include "chrome/browser/prefs/scoped_user_pref_update.h"
66 #include "chrome/browser/prerender/prerender_field_trial.h" 67 #include "chrome/browser/prerender/prerender_field_trial.h"
67 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 68 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
68 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 69 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
69 #include "chrome/browser/process_singleton.h" 70 #include "chrome/browser/process_singleton.h"
70 #include "chrome/browser/profiles/profile.h" 71 #include "chrome/browser/profiles/profile.h"
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1356 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1356 chrome_extra_parts_[i]->PostProfileInit(); 1357 chrome_extra_parts_[i]->PostProfileInit();
1357 } 1358 }
1358 1359
1359 void ChromeBrowserMainParts::PreBrowserStart() { 1360 void ChromeBrowserMainParts::PreBrowserStart() {
1360 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1361 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1361 chrome_extra_parts_[i]->PreBrowserStart(); 1362 chrome_extra_parts_[i]->PreBrowserStart();
1362 } 1363 }
1363 1364
1364 void ChromeBrowserMainParts::PostBrowserStart() { 1365 void ChromeBrowserMainParts::PostBrowserStart() {
1366 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kVisitURLs))
1367 RunPageCycler();
1368
1365 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1369 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1366 chrome_extra_parts_[i]->PostBrowserStart(); 1370 chrome_extra_parts_[i]->PostBrowserStart();
1367 // Allow ProcessSingleton to process messages. 1371 // Allow ProcessSingleton to process messages.
1368 process_singleton_->Unlock(); 1372 process_singleton_->Unlock();
1369 } 1373 }
1370 1374
1375 void ChromeBrowserMainParts::RunPageCycler() {
1376 CommandLine* command_line = CommandLine::ForCurrentProcess();
1377 Browser* browser = BrowserList::GetLastActive();
1378 DCHECK(browser);
1379 PageCycler* page_cycler = NULL;
1380 FilePath input_file =
1381 command_line->GetSwitchValuePath(switches::kVisitURLs);
1382 if (command_line->HasSwitch(switches::kRecordStats)) {
1383 page_cycler = new PageCycler(
1384 browser,
1385 input_file,
1386 input_file.ReplaceExtension(".errors"),
1387 command_line->GetSwitchValuePath(switches::kRecordStats));
1388 } else {
1389 page_cycler = new PageCycler(browser,
1390 input_file,
1391 input_file.ReplaceExtension(".errors"));
1392 }
1393 if (command_line->HasSwitch(switches::kVisitURLsCount)) {
1394 unsigned int iterations = 0;
Aaron Boodman 2012/03/20 19:28:16 We don't use unsigned integers in Chrome, except f
1395 CHECK(base::StringToUint(
1396 command_line->GetSwitchValueNative(switches::kVisitURLsCount),
1397 &iterations));
1398 page_cycler->Run(iterations);
Aaron Boodman 2012/03/20 19:28:16 Nit: define interations outside the check for kVis
1399 } else {
1400 page_cycler->Run(1);
1401 }
1402 }
1403
1371 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { 1404 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
1372 // Now that the file thread has been started, start recording. 1405 // Now that the file thread has been started, start recording.
1373 StartMetricsRecording(); 1406 StartMetricsRecording();
1374 1407
1375 #if defined(USE_LINUX_BREAKPAD) 1408 #if defined(USE_LINUX_BREAKPAD)
1376 // Needs to be called after we have chrome::DIR_USER_DATA and 1409 // Needs to be called after we have chrome::DIR_USER_DATA and
1377 // g_browser_process. This happens in PreCreateThreads. 1410 // g_browser_process. This happens in PreCreateThreads.
1378 BrowserThread::PostTask(BrowserThread::FILE, 1411 BrowserThread::PostTask(BrowserThread::FILE,
1379 FROM_HERE, 1412 FROM_HERE,
1380 base::Bind(&GetLinuxDistroCallback)); 1413 base::Bind(&GetLinuxDistroCallback));
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 if (base::win::GetVersion() <= base::win::VERSION_XP) 1985 if (base::win::GetVersion() <= base::win::VERSION_XP)
1953 uma_name += "_XP"; 1986 uma_name += "_XP";
1954 1987
1955 uma_name += "_PreRead_"; 1988 uma_name += "_PreRead_";
1956 uma_name += pre_read_percentage; 1989 uma_name += pre_read_percentage;
1957 AddPreReadHistogramTime(uma_name.c_str(), time); 1990 AddPreReadHistogramTime(uma_name.c_str(), time);
1958 } 1991 }
1959 #endif 1992 #endif
1960 #endif 1993 #endif
1961 } 1994 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698