OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 | 664 |
665 // BrowserMainParts ------------------------------------------------------------ | 665 // BrowserMainParts ------------------------------------------------------------ |
666 | 666 |
667 ChromeBrowserMainParts::ChromeBrowserMainParts( | 667 ChromeBrowserMainParts::ChromeBrowserMainParts( |
668 const MainFunctionParams& parameters) | 668 const MainFunctionParams& parameters) |
669 : BrowserMainParts(parameters), | 669 : BrowserMainParts(parameters), |
670 shutdown_watcher_(new ShutdownWatcherHelper()), | 670 shutdown_watcher_(new ShutdownWatcherHelper()), |
671 record_search_engine_(false), | 671 record_search_engine_(false), |
672 translate_manager_(NULL), | 672 translate_manager_(NULL), |
673 profile_(NULL), | 673 profile_(NULL), |
674 run_message_loop_(true) { | 674 run_message_loop_(true), |
| 675 notify_result_(ProcessSingleton::PROCESS_NONE) { |
675 // If we're running tests (ui_task is non-null). | 676 // If we're running tests (ui_task is non-null). |
676 if (parameters.ui_task) | 677 if (parameters.ui_task) |
677 browser_defaults::enable_help_app = false; | 678 browser_defaults::enable_help_app = false; |
678 } | 679 } |
679 | 680 |
680 ChromeBrowserMainParts::~ChromeBrowserMainParts() { | 681 ChromeBrowserMainParts::~ChromeBrowserMainParts() { |
681 } | 682 } |
682 | 683 |
683 // This will be called after the command-line has been mutated by about:flags | 684 // This will be called after the command-line has been mutated by about:flags |
684 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( | 685 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 // from other browsers. In case this process is a short-lived "import" | 1349 // from other browsers. In case this process is a short-lived "import" |
1349 // process that another browser runs just to import the settings, we | 1350 // process that another browser runs just to import the settings, we |
1350 // don't want to be checking for another browser process, by design. | 1351 // don't want to be checking for another browser process, by design. |
1351 if (!(parsed_command_line().HasSwitch(switches::kImport) || | 1352 if (!(parsed_command_line().HasSwitch(switches::kImport) || |
1352 parsed_command_line().HasSwitch(switches::kImportFromFile))) { | 1353 parsed_command_line().HasSwitch(switches::kImportFromFile))) { |
1353 #endif | 1354 #endif |
1354 // When another process is running, use that process instead of starting a | 1355 // When another process is running, use that process instead of starting a |
1355 // new one. NotifyOtherProcess will currently give the other process up to | 1356 // new one. NotifyOtherProcess will currently give the other process up to |
1356 // 20 seconds to respond. Note that this needs to be done before we attempt | 1357 // 20 seconds to respond. Note that this needs to be done before we attempt |
1357 // to read the profile. | 1358 // to read the profile. |
1358 switch (process_singleton_->NotifyOtherProcessOrCreate()) { | 1359 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); |
| 1360 switch (notify_result_) { |
1359 case ProcessSingleton::PROCESS_NONE: | 1361 case ProcessSingleton::PROCESS_NONE: |
1360 // No process already running, fall through to starting a new one. | 1362 // No process already running, fall through to starting a new one. |
1361 break; | 1363 break; |
1362 | 1364 |
1363 case ProcessSingleton::PROCESS_NOTIFIED: | 1365 case ProcessSingleton::PROCESS_NOTIFIED: |
1364 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1366 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
1365 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( | 1367 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( |
1366 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1368 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); |
1367 #endif | 1369 #endif |
1368 return content::RESULT_CODE_NORMAL_EXIT; | 1370 return content::RESULT_CODE_NORMAL_EXIT; |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 #if defined(OS_CHROMEOS) | 1875 #if defined(OS_CHROMEOS) |
1874 browser::OomPriorityManager::GetInstance()->Stop(); | 1876 browser::OomPriorityManager::GetInstance()->Stop(); |
1875 #endif | 1877 #endif |
1876 | 1878 |
1877 // Some tests don't set parameters.ui_task, so they started translate | 1879 // Some tests don't set parameters.ui_task, so they started translate |
1878 // language fetch that was never completed so we need to cleanup here | 1880 // language fetch that was never completed so we need to cleanup here |
1879 // otherwise it will be done by the destructor in a wrong thread. | 1881 // otherwise it will be done by the destructor in a wrong thread. |
1880 if (parameters().ui_task == NULL && translate_manager_ != NULL) | 1882 if (parameters().ui_task == NULL && translate_manager_ != NULL) |
1881 translate_manager_->CleanupPendingUlrFetcher(); | 1883 translate_manager_->CleanupPendingUlrFetcher(); |
1882 | 1884 |
1883 process_singleton_->Cleanup(); | 1885 if (notify_result_ == ProcessSingleton::PROCESS_NONE) |
| 1886 process_singleton_->Cleanup(); |
1884 | 1887 |
1885 // Stop all tasks that might run on WatchDogThread. | 1888 // Stop all tasks that might run on WatchDogThread. |
1886 ThreadWatcherList::StopWatchingAll(); | 1889 ThreadWatcherList::StopWatchingAll(); |
1887 | 1890 |
1888 g_browser_process->metrics_service()->Stop(); | 1891 g_browser_process->metrics_service()->Stop(); |
1889 | 1892 |
1890 // browser_shutdown takes care of deleting browser_process, so we need to | 1893 // browser_shutdown takes care of deleting browser_process, so we need to |
1891 // release it. | 1894 // release it. |
1892 ignore_result(browser_process_.release()); | 1895 ignore_result(browser_process_.release()); |
1893 browser_shutdown::Shutdown(); | 1896 browser_shutdown::Shutdown(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 1936 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
1934 (pre_read == "0" || pre_read == "1")) { | 1937 (pre_read == "0" || pre_read == "1")) { |
1935 std::string uma_name(name); | 1938 std::string uma_name(name); |
1936 uma_name += "_PreRead"; | 1939 uma_name += "_PreRead"; |
1937 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 1940 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
1938 AddPreReadHistogramTime(uma_name.c_str(), time); | 1941 AddPreReadHistogramTime(uma_name.c_str(), time); |
1939 } | 1942 } |
1940 #endif | 1943 #endif |
1941 #endif | 1944 #endif |
1942 } | 1945 } |
OLD | NEW |