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> |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 std::string(sizeof(sockaddr_un::sun_path), 'a')); | 90 std::string(sizeof(sockaddr_un::sun_path), 'a')); |
91 ASSERT_TRUE(CreateDirectory(user_data_path_)); | 91 ASSERT_TRUE(CreateDirectory(user_data_path_)); |
92 | 92 |
93 lock_path_ = user_data_path_.Append(chrome::kSingletonLockFilename); | 93 lock_path_ = user_data_path_.Append(chrome::kSingletonLockFilename); |
94 socket_path_ = user_data_path_.Append(chrome::kSingletonSocketFilename); | 94 socket_path_ = user_data_path_.Append(chrome::kSingletonSocketFilename); |
95 cookie_path_ = user_data_path_.Append(chrome::kSingletonCookieFilename); | 95 cookie_path_ = user_data_path_.Append(chrome::kSingletonCookieFilename); |
96 } | 96 } |
97 | 97 |
98 void TearDown() override { | 98 void TearDown() override { |
99 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( | 99 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( |
100 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); | 100 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get())); |
101 ASSERT_TRUE(io_helper->Run()); | 101 ASSERT_TRUE(io_helper->Run()); |
102 | 102 |
103 // Destruct the ProcessSingleton object before the IO thread so that its | 103 // Destruct the ProcessSingleton object before the IO thread so that its |
104 // internals are destructed properly. | 104 // internals are destructed properly. |
105 if (process_singleton_on_thread_) { | 105 if (process_singleton_on_thread_) { |
106 worker_thread_->task_runner()->PostTask( | 106 worker_thread_->task_runner()->PostTask( |
107 FROM_HERE, | 107 FROM_HERE, |
108 base::Bind(&ProcessSingletonPosixTest::DestructProcessSingleton, | 108 base::Bind(&ProcessSingletonPosixTest::DestructProcessSingleton, |
109 base::Unretained(this))); | 109 base::Unretained(this))); |
110 | 110 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // 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 |
428 // it. | 428 // it. |
429 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) { | 429 TEST_F(ProcessSingletonPosixTest, CreateReplacesOldMacLock) { |
430 std::unique_ptr<TestableProcessSingleton> process_singleton( | 430 std::unique_ptr<TestableProcessSingleton> process_singleton( |
431 CreateProcessSingleton()); | 431 CreateProcessSingleton()); |
432 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0)); | 432 EXPECT_EQ(0, base::WriteFile(lock_path_, "", 0)); |
433 EXPECT_TRUE(process_singleton->Create()); | 433 EXPECT_TRUE(process_singleton->Create()); |
434 VerifyFiles(); | 434 VerifyFiles(); |
435 } | 435 } |
436 #endif // defined(OS_MACOSX) | 436 #endif // defined(OS_MACOSX) |
OLD | NEW |