| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/process_singleton.h" | 5 #include "chrome/browser/process_singleton.h" |
| 6 | 6 |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 #include <sys/wait.h> | 8 #include <sys/wait.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 #include <vector> | 11 #include <vector> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/eintr_wrapper.h" | 14 #include "base/eintr_wrapper.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/thread.h" | 18 #include "base/thread.h" |
| 19 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/test/chrome_process_util.h" | 24 #include "chrome/test/chrome_process_util.h" |
| 25 #include "chrome/test/ui/ui_test.h" | 25 #include "chrome/test/ui/ui_test.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 27 |
| 28 | |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 typedef UITest ProcessSingletonLinuxTest; | 30 typedef UITest ProcessSingletonLinuxTest; |
| 32 | 31 |
| 33 // A helper method to call ProcessSingleton::NotifyOtherProcess(). | 32 // A helper method to call ProcessSingleton::NotifyOtherProcess(). |
| 34 // |url| will be added to CommandLine for current process, so that it can be | 33 // |url| will be added to CommandLine for current process, so that it can be |
| 35 // sent to browser process by ProcessSingleton::NotifyOtherProcess(). | 34 // sent to browser process by ProcessSingleton::NotifyOtherProcess(). |
| 36 ProcessSingleton::NotifyResult NotifyOtherProcess(const std::string& url) { | 35 ProcessSingleton::NotifyResult NotifyOtherProcess(const std::string& url) { |
| 37 FilePath user_data_dir; | 36 FilePath user_data_dir; |
| 38 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 37 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // Wait for a while to make sure the browser process is actually killed. | 140 // Wait for a while to make sure the browser process is actually killed. |
| 142 EXPECT_FALSE(CrashAwareSleep(1000)); | 141 EXPECT_FALSE(CrashAwareSleep(1000)); |
| 143 | 142 |
| 144 FilePath lock_path = user_data_dir().Append(chrome::kSingletonLockFilename); | 143 FilePath lock_path = user_data_dir().Append(chrome::kSingletonLockFilename); |
| 145 EXPECT_EQ(0, unlink(lock_path.value().c_str())); | 144 EXPECT_EQ(0, unlink(lock_path.value().c_str())); |
| 146 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path.value().c_str())); | 145 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path.value().c_str())); |
| 147 | 146 |
| 148 std::string url("about:blank"); | 147 std::string url("about:blank"); |
| 149 EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, NotifyOtherProcess(url)); | 148 EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, NotifyOtherProcess(url)); |
| 150 } | 149 } |
| OLD | NEW |