| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/internal_api/public/util/weak_handle.h" | 5 #include "sync/internal_api/public/util/weak_handle.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 MOCK_METHOD1(TestWithSelf, void(const WeakHandle<Base>&)); | 40 MOCK_METHOD1(TestWithSelf, void(const WeakHandle<Base>&)); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 base::WeakPtrFactory<Base> weak_ptr_factory_; | 43 base::WeakPtrFactory<Base> weak_ptr_factory_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 class Derived : public Base, public base::SupportsWeakPtr<Derived> {}; | 46 class Derived : public Base, public base::SupportsWeakPtr<Derived> {}; |
| 47 | 47 |
| 48 class WeakHandleTest : public ::testing::Test { | 48 class WeakHandleTest : public ::testing::Test { |
| 49 protected: | 49 protected: |
| 50 virtual void TearDown() { | 50 void TearDown() override { |
| 51 // Process any last-minute posted tasks. | 51 // Process any last-minute posted tasks. |
| 52 PumpLoop(); | 52 PumpLoop(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void PumpLoop() { | 55 void PumpLoop() { |
| 56 message_loop_.RunUntilIdle(); | 56 message_loop_.RunUntilIdle(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 static void CallTestFromOtherThread(tracked_objects::Location from_here, | 59 static void CallTestFromOtherThread(tracked_objects::Location from_here, |
| 60 const WeakHandle<Base>& h) { | 60 const WeakHandle<Base>& h) { |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 EXPECT_FALSE(base_weak_handle.IsInitialized()); | 317 EXPECT_FALSE(base_weak_handle.IsInitialized()); |
| 318 } | 318 } |
| 319 | 319 |
| 320 TEST_F(WeakHandleTest, TypeConversionConstructorUninitializedAssignment) { | 320 TEST_F(WeakHandleTest, TypeConversionConstructorUninitializedAssignment) { |
| 321 WeakHandle<Base> base_weak_handle; | 321 WeakHandle<Base> base_weak_handle; |
| 322 base_weak_handle = WeakHandle<Derived>(); | 322 base_weak_handle = WeakHandle<Derived>(); |
| 323 EXPECT_FALSE(base_weak_handle.IsInitialized()); | 323 EXPECT_FALSE(base_weak_handle.IsInitialized()); |
| 324 } | 324 } |
| 325 | 325 |
| 326 } // namespace syncer | 326 } // namespace syncer |
| OLD | NEW |