OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <fcntl.h> | 7 #include <fcntl.h> |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <signal.h> | 9 #include <signal.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 #include <sys/types.h> | 11 #include <sys/types.h> |
12 #include <sys/un.h> | 12 #include <sys/un.h> |
13 #include <sys/wait.h> | 13 #include <sys/wait.h> |
14 #include <unistd.h> | 14 #include <unistd.h> |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 #include <string> | 17 #include <string> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "base/bind.h" | 20 #include "base/bind.h" |
21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
22 #include "base/files/file_path.h" | 22 #include "base/files/file_path.h" |
23 #include "base/files/file_util.h" | 23 #include "base/files/file_util.h" |
24 #include "base/files/scoped_temp_dir.h" | 24 #include "base/files/scoped_temp_dir.h" |
25 #include "base/location.h" | 25 #include "base/location.h" |
26 #include "base/posix/eintr_wrapper.h" | 26 #include "base/posix/eintr_wrapper.h" |
27 #include "base/single_thread_task_runner.h" | 27 #include "base/single_thread_task_runner.h" |
28 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
29 #include "base/synchronization/waitable_event.h" | 29 #include "base/synchronization/waitable_event.h" |
30 #include "base/test/scoped_task_environment.h" | |
31 #include "base/test/test_timeouts.h" | 30 #include "base/test/test_timeouts.h" |
32 #include "base/test/thread_test_helper.h" | 31 #include "base/test/thread_test_helper.h" |
33 #include "base/threading/thread.h" | 32 #include "base/threading/thread.h" |
34 #include "build/build_config.h" | 33 #include "build/build_config.h" |
35 #include "chrome/common/chrome_constants.h" | 34 #include "chrome/common/chrome_constants.h" |
36 #include "content/public/test/test_browser_thread.h" | 35 #include "content/public/test/test_browser_thread.h" |
37 #include "net/base/network_interfaces.h" | 36 #include "net/base/network_interfaces.h" |
38 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
39 | 38 |
40 using content::BrowserThread; | 39 using content::BrowserThread; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 250 |
252 void DestructProcessSingleton() { | 251 void DestructProcessSingleton() { |
253 ASSERT_TRUE(process_singleton_on_thread_); | 252 ASSERT_TRUE(process_singleton_on_thread_); |
254 delete process_singleton_on_thread_; | 253 delete process_singleton_on_thread_; |
255 } | 254 } |
256 | 255 |
257 void KillCallback(int pid) { | 256 void KillCallback(int pid) { |
258 kill_callbacks_++; | 257 kill_callbacks_++; |
259 } | 258 } |
260 | 259 |
261 base::test::ScopedTaskEnvironment scoped_task_environment_; | 260 base::MessageLoop message_loop_; |
262 content::TestBrowserThread io_thread_; | 261 content::TestBrowserThread io_thread_; |
263 base::ScopedTempDir temp_dir_; | 262 base::ScopedTempDir temp_dir_; |
264 base::WaitableEvent wait_event_; | 263 base::WaitableEvent wait_event_; |
265 base::WaitableEvent signal_event_; | 264 base::WaitableEvent signal_event_; |
266 | 265 |
267 std::unique_ptr<base::Thread> worker_thread_; | 266 std::unique_ptr<base::Thread> worker_thread_; |
268 TestableProcessSingleton* process_singleton_on_thread_; | 267 TestableProcessSingleton* process_singleton_on_thread_; |
269 }; | 268 }; |
270 | 269 |
271 } // namespace | 270 } // namespace |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 // Test that if there is an existing lock file, and it's not locked, we replace | 427 // Test that if there is an existing lock file, and it's not locked, we replace |
429 // it. | 428 // it. |
430 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) { | 429 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) { |
431 std::unique_ptr<TestableProcessSingleton> process_singleton( | 430 std::unique_ptr<TestableProcessSingleton> process_singleton( |
432 CreateProcessSingleton()); | 431 CreateProcessSingleton()); |
433 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0)); | 432 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0)); |
434 EXPECT_TRUE(process_singleton->Create()); | 433 EXPECT_TRUE(process_singleton->Create()); |
435 VerifyFiles(); | 434 VerifyFiles(); |
436 } | 435 } |
437 #endif // defined(OS_MACOSX) | 436 #endif // defined(OS_MACOSX) |
OLD | NEW |