| 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 "base/basictypes.h" | |
| 6 #include "base/environment.h" | 5 #include "base/environment.h" |
| 7 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/process/kill.h" | 9 #include "base/process/kill.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/test/multiprocess_test.h" | 12 #include "base/test/multiprocess_test.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "build/build_config.h" |
| 14 #include "chrome/common/multi_process_lock.h" | 15 #include "chrome/common/multi_process_lock.h" |
| 15 #include "testing/multiprocess_func_list.h" | 16 #include "testing/multiprocess_func_list.h" |
| 16 | 17 |
| 17 class MultiProcessLockTest : public base::MultiProcessTest { | 18 class MultiProcessLockTest : public base::MultiProcessTest { |
| 18 public: | 19 public: |
| 19 static const char kLockEnviromentVarName[]; | 20 static const char kLockEnviromentVarName[]; |
| 20 | 21 |
| 21 class ScopedEnvironmentVariable { | 22 class ScopedEnvironmentVariable { |
| 22 public: | 23 public: |
| 23 ScopedEnvironmentVariable(const std::string &name, | 24 ScopedEnvironmentVariable(const std::string &name, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 EXPECT_TRUE(environment->GetVar(MultiProcessLockTest::kLockEnviromentVarName, | 169 EXPECT_TRUE(environment->GetVar(MultiProcessLockTest::kLockEnviromentVarName, |
| 169 &name)); | 170 &name)); |
| 170 scoped_ptr<MultiProcessLock> test_lock( | 171 scoped_ptr<MultiProcessLock> test_lock( |
| 171 MultiProcessLock::Create(name)); | 172 MultiProcessLock::Create(name)); |
| 172 | 173 |
| 173 // Expect locking to succeed because it is not claimed yet. | 174 // Expect locking to succeed because it is not claimed yet. |
| 174 bool locked_successfully = test_lock->TryLock(); | 175 bool locked_successfully = test_lock->TryLock(); |
| 175 EXPECT_TRUE(locked_successfully); | 176 EXPECT_TRUE(locked_successfully); |
| 176 return !locked_successfully; | 177 return !locked_successfully; |
| 177 } | 178 } |
| OLD | NEW |