| 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/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/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/string_util.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
| 18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/test/chrome_process_util.h" | 23 #include "chrome/test/chrome_process_util.h" |
| 24 #include "chrome/test/ui/ui_test.h" | 24 #include "chrome/test/ui/ui_test.h" |
| 25 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // Test that we don't kill ourselves by accident if a lockfile with the same pid | 180 // Test that we don't kill ourselves by accident if a lockfile with the same pid |
| 181 // happens to exist. | 181 // happens to exist. |
| 182 // TODO(mattm): This doesn't really need to be a uitest. (We don't use the | 182 // TODO(mattm): This doesn't really need to be a uitest. (We don't use the |
| 183 // uitest created browser process, but we do use some uitest provided stuff like | 183 // uitest created browser process, but we do use some uitest provided stuff like |
| 184 // the user_data_dir and the NotifyOtherProcess function in this file, which | 184 // the user_data_dir and the NotifyOtherProcess function in this file, which |
| 185 // would have to be duplicated or shared if this test was moved into a | 185 // would have to be duplicated or shared if this test was moved into a |
| 186 // unittest.) | 186 // unittest.) |
| 187 TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessNoSuicide) { | 187 TEST_F(ProcessSingletonLinuxTest, NotifyOtherProcessNoSuicide) { |
| 188 // Replace lockfile with one containing our own pid. | 188 // Replace lockfile with one containing our own pid. |
| 189 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); | 189 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); |
| 190 std::string symlink_content = StringPrintf( | 190 std::string symlink_content = base::StringPrintf( |
| 191 "%s%c%u", | 191 "%s%c%u", |
| 192 net::GetHostName().c_str(), | 192 net::GetHostName().c_str(), |
| 193 '-', | 193 '-', |
| 194 base::GetCurrentProcId()); | 194 base::GetCurrentProcId()); |
| 195 EXPECT_EQ(0, symlink(symlink_content.c_str(), lock_path_.value().c_str())); | 195 EXPECT_EQ(0, symlink(symlink_content.c_str(), lock_path_.value().c_str())); |
| 196 | 196 |
| 197 // Remove socket so that we will not be able to notify the existing browser. | 197 // Remove socket so that we will not be able to notify the existing browser. |
| 198 EXPECT_EQ(0, unlink(socket_path_.value().c_str())); | 198 EXPECT_EQ(0, unlink(socket_path_.value().c_str())); |
| 199 | 199 |
| 200 std::string url("about:blank"); | 200 std::string url("about:blank"); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 EXPECT_EQ(0, symlink("INCORRECTCOOKIE", cookie_path_.value().c_str())); | 300 EXPECT_EQ(0, symlink("INCORRECTCOOKIE", cookie_path_.value().c_str())); |
| 301 | 301 |
| 302 // Also change the hostname, so the remote does not retry. | 302 // Also change the hostname, so the remote does not retry. |
| 303 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); | 303 EXPECT_EQ(0, unlink(lock_path_.value().c_str())); |
| 304 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str())); | 304 EXPECT_EQ(0, symlink("FAKEFOOHOST-1234", lock_path_.value().c_str())); |
| 305 | 305 |
| 306 std::string url("about:blank"); | 306 std::string url("about:blank"); |
| 307 EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, | 307 EXPECT_EQ(ProcessSingleton::PROFILE_IN_USE, |
| 308 NotifyOtherProcessOrCreate(url, TestTimeouts::action_timeout_ms())); | 308 NotifyOtherProcessOrCreate(url, TestTimeouts::action_timeout_ms())); |
| 309 } | 309 } |
| OLD | NEW |