OLD | NEW |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 #include "net/socket/client_socket_pool_base.h" | 112 #include "net/socket/client_socket_pool_base.h" |
113 #include "net/socket/client_socket_pool_manager.h" | 113 #include "net/socket/client_socket_pool_manager.h" |
114 #include "net/spdy/spdy_session.h" | 114 #include "net/spdy/spdy_session.h" |
115 #include "net/spdy/spdy_session_pool.h" | 115 #include "net/spdy/spdy_session_pool.h" |
116 #include "net/url_request/url_request.h" | 116 #include "net/url_request/url_request.h" |
117 #include "net/url_request/url_request_throttler_manager.h" | 117 #include "net/url_request/url_request_throttler_manager.h" |
118 #include "net/websockets/websocket_job.h" | 118 #include "net/websockets/websocket_job.h" |
119 #include "ui/base/l10n/l10n_util.h" | 119 #include "ui/base/l10n/l10n_util.h" |
120 #include "ui/base/resource/resource_bundle.h" | 120 #include "ui/base/resource/resource_bundle.h" |
121 | 121 |
122 #if defined(USE_LINUX_BREAKPAD) | 122 #if defined(USE_POSIX_BREAKPAD) |
123 #include "base/linux_util.h" | 123 #include "base/linux_util.h" |
124 #include "chrome/app/breakpad_linux.h" | 124 #include "chrome/app/breakpad_posix.h" |
125 #endif | 125 #endif |
126 | 126 |
127 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 127 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
128 #include "chrome/browser/first_run/upgrade_util_linux.h" | 128 #include "chrome/browser/first_run/upgrade_util_linux.h" |
129 #endif | 129 #endif |
130 | 130 |
131 #if defined(OS_CHROMEOS) | 131 #if defined(OS_CHROMEOS) |
132 #include "chrome/browser/chromeos/cros/cros_library.h" | 132 #include "chrome/browser/chromeos/cros/cros_library.h" |
133 #include "chrome/browser/chromeos/cros_settings.h" | 133 #include "chrome/browser/chromeos/cros_settings.h" |
134 #include "chrome/browser/chromeos/cros_settings_names.h" | 134 #include "chrome/browser/chromeos/cros_settings_names.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 void AddFirstRunNewTabs(BrowserInit* browser_init, | 218 void AddFirstRunNewTabs(BrowserInit* browser_init, |
219 const std::vector<GURL>& new_tabs) { | 219 const std::vector<GURL>& new_tabs) { |
220 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); | 220 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); |
221 it != new_tabs.end(); ++it) { | 221 it != new_tabs.end(); ++it) { |
222 if (it->is_valid()) | 222 if (it->is_valid()) |
223 browser_init->AddFirstRunTab(*it); | 223 browser_init->AddFirstRunTab(*it); |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 #if defined(USE_LINUX_BREAKPAD) | 227 #if defined(USE_POSIX_BREAKPAD) |
228 void GetLinuxDistroCallback() { | 228 void GetLinuxDistroCallback() { |
229 base::GetLinuxDistro(); // Initialize base::linux_distro if needed. | 229 base::GetLinuxDistro(); // Initialize base::linux_distro if needed. |
230 } | 230 } |
231 #endif // USE_LINUX_BREAKPAD | 231 #endif // USE_POSIX_BREAKPAD |
232 | 232 |
233 void InitializeNetworkOptions(const CommandLine& parsed_command_line) { | 233 void InitializeNetworkOptions(const CommandLine& parsed_command_line) { |
234 if (parsed_command_line.HasSwitch(switches::kEnableFileCookies)) { | 234 if (parsed_command_line.HasSwitch(switches::kEnableFileCookies)) { |
235 // Enable cookie storage for file:// URLs. Must do this before the first | 235 // Enable cookie storage for file:// URLs. Must do this before the first |
236 // Profile (and therefore the first CookieMonster) is created. | 236 // Profile (and therefore the first CookieMonster) is created. |
237 net::CookieMonster::EnableFileScheme(); | 237 net::CookieMonster::EnableFileScheme(); |
238 } | 238 } |
239 | 239 |
240 if (parsed_command_line.HasSwitch(switches::kIgnoreCertificateErrors)) | 240 if (parsed_command_line.HasSwitch(switches::kIgnoreCertificateErrors)) |
241 net::HttpStreamFactory::set_ignore_certificate_errors(true); | 241 net::HttpStreamFactory::set_ignore_certificate_errors(true); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 void SetSocketReusePolicy(int warmest_socket_trial_group, | 501 void SetSocketReusePolicy(int warmest_socket_trial_group, |
502 const int socket_policy[], | 502 const int socket_policy[], |
503 int num_groups) { | 503 int num_groups) { |
504 const int* result = std::find(socket_policy, socket_policy + num_groups, | 504 const int* result = std::find(socket_policy, socket_policy + num_groups, |
505 warmest_socket_trial_group); | 505 warmest_socket_trial_group); |
506 DCHECK_NE(result, socket_policy + num_groups) | 506 DCHECK_NE(result, socket_policy + num_groups) |
507 << "Not a valid socket reuse policy group"; | 507 << "Not a valid socket reuse policy group"; |
508 net::SetSocketReusePolicy(result - socket_policy); | 508 net::SetSocketReusePolicy(result - socket_policy); |
509 } | 509 } |
510 | 510 |
511 #if defined(USE_LINUX_BREAKPAD) | 511 #if defined(USE_POSIX_BREAKPAD) |
512 bool IsCrashReportingEnabled(const PrefService* local_state) { | 512 bool IsCrashReportingEnabled(const PrefService* local_state) { |
513 // Check whether we should initialize the crash reporter. It may be disabled | 513 // Check whether we should initialize the crash reporter. It may be disabled |
514 // through configuration policy or user preference. It must be disabled for | 514 // through configuration policy or user preference. It must be disabled for |
515 // Guest mode on Chrome OS in Stable channel. | 515 // Guest mode on Chrome OS in Stable channel. |
516 // The kHeadless environment variable overrides the decision, but only if the | 516 // The kHeadless environment variable overrides the decision, but only if the |
517 // crash service is under control of the user. It is used by QA testing | 517 // crash service is under control of the user. It is used by QA testing |
518 // infrastructure to switch on generation of crash reports. | 518 // infrastructure to switch on generation of crash reports. |
519 #if defined(OS_CHROMEOS) | 519 #if defined(OS_CHROMEOS) |
520 bool is_guest_session = | 520 bool is_guest_session = |
521 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); | 521 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); |
(...skipping 11 matching lines...) Expand all Loading... |
533 const PrefService::Preference* metrics_reporting_enabled = | 533 const PrefService::Preference* metrics_reporting_enabled = |
534 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 534 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
535 CHECK(metrics_reporting_enabled); | 535 CHECK(metrics_reporting_enabled); |
536 bool breakpad_enabled = | 536 bool breakpad_enabled = |
537 local_state->GetBoolean(prefs::kMetricsReportingEnabled); | 537 local_state->GetBoolean(prefs::kMetricsReportingEnabled); |
538 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) | 538 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) |
539 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; | 539 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; |
540 #endif // #if defined(OS_CHROMEOS) | 540 #endif // #if defined(OS_CHROMEOS) |
541 return breakpad_enabled; | 541 return breakpad_enabled; |
542 } | 542 } |
543 #endif // #if defined(USE_LINUX_BREAKPAD) | 543 #endif // #if defined(USE_POSIX_BREAKPAD) |
544 | 544 |
545 // This code is specific to the Windows-only PreReadExperiment field-trial. | 545 // This code is specific to the Windows-only PreReadExperiment field-trial. |
546 void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { | 546 void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { |
547 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); | 547 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); |
548 const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); | 548 const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); |
549 static const size_t kBuckets(100); | 549 static const size_t kBuckets(100); |
550 | 550 |
551 // FactoryTimeGet will always return a pointer to the same histogram object, | 551 // FactoryTimeGet will always return a pointer to the same histogram object, |
552 // keyed on its name. There's no need for us to store it explicitly anywhere. | 552 // keyed on its name. There's no need for us to store it explicitly anywhere. |
553 base::Histogram* counter = base::Histogram::FactoryTimeGet( | 553 base::Histogram* counter = base::Histogram::FactoryTimeGet( |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1362 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1363 chrome_extra_parts_[i]->PostBrowserStart(); | 1363 chrome_extra_parts_[i]->PostBrowserStart(); |
1364 // Allow ProcessSingleton to process messages. | 1364 // Allow ProcessSingleton to process messages. |
1365 process_singleton_->Unlock(); | 1365 process_singleton_->Unlock(); |
1366 } | 1366 } |
1367 | 1367 |
1368 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { | 1368 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
1369 // Now that the file thread has been started, start recording. | 1369 // Now that the file thread has been started, start recording. |
1370 StartMetricsRecording(); | 1370 StartMetricsRecording(); |
1371 | 1371 |
1372 #if defined(USE_LINUX_BREAKPAD) | 1372 #if defined(USE_POSIX_BREAKPAD) |
1373 // Needs to be called after we have chrome::DIR_USER_DATA and | 1373 // Needs to be called after we have chrome::DIR_USER_DATA and |
1374 // g_browser_process. This happens in PreCreateThreads. | 1374 // g_browser_process. This happens in PreCreateThreads. |
1375 BrowserThread::PostTask(BrowserThread::FILE, | 1375 BrowserThread::PostTask(BrowserThread::FILE, |
1376 FROM_HERE, | 1376 FROM_HERE, |
1377 base::Bind(&GetLinuxDistroCallback)); | 1377 base::Bind(&GetLinuxDistroCallback)); |
1378 | 1378 |
1379 if (IsCrashReportingEnabled(local_state_)) | 1379 if (IsCrashReportingEnabled(local_state_)) |
1380 InitCrashReporter(); | 1380 InitCrashReporter(); |
1381 #endif | 1381 #endif |
1382 | 1382 |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1943 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1944 uma_name += "_XP"; | 1944 uma_name += "_XP"; |
1945 | 1945 |
1946 uma_name += "_PreRead_"; | 1946 uma_name += "_PreRead_"; |
1947 uma_name += pre_read_percentage; | 1947 uma_name += pre_read_percentage; |
1948 AddPreReadHistogramTime(uma_name.c_str(), time); | 1948 AddPreReadHistogramTime(uma_name.c_str(), time); |
1949 } | 1949 } |
1950 #endif | 1950 #endif |
1951 #endif | 1951 #endif |
1952 } | 1952 } |
OLD | NEW |