| 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/notifier/non_blocking_invalidator.h" | 5 #include "sync/notifier/non_blocking_invalidator.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 class NonBlockingInvalidatorTestDelegate { | 27 class NonBlockingInvalidatorTestDelegate { |
| 28 public: | 28 public: |
| 29 NonBlockingInvalidatorTestDelegate() : io_thread_("IO thread") {} | 29 NonBlockingInvalidatorTestDelegate() : io_thread_("IO thread") {} |
| 30 | 30 |
| 31 ~NonBlockingInvalidatorTestDelegate() { | 31 ~NonBlockingInvalidatorTestDelegate() { |
| 32 DestroyInvalidator(); | 32 DestroyInvalidator(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void CreateInvalidator( | 35 void CreateInvalidator( |
| 36 const std::string& invalidator_client_id, |
| 36 const std::string& initial_state, | 37 const std::string& initial_state, |
| 37 const base::WeakPtr<InvalidationStateTracker>& | 38 const base::WeakPtr<InvalidationStateTracker>& |
| 38 invalidation_state_tracker) { | 39 invalidation_state_tracker) { |
| 39 DCHECK(!invalidator_.get()); | 40 DCHECK(!invalidator_.get()); |
| 40 base::Thread::Options options; | 41 base::Thread::Options options; |
| 41 options.message_loop_type = MessageLoop::TYPE_IO; | 42 options.message_loop_type = MessageLoop::TYPE_IO; |
| 42 io_thread_.StartWithOptions(options); | 43 io_thread_.StartWithOptions(options); |
| 43 request_context_getter_ = | 44 request_context_getter_ = |
| 44 new net::TestURLRequestContextGetter(io_thread_.message_loop_proxy()); | 45 new net::TestURLRequestContextGetter(io_thread_.message_loop_proxy()); |
| 45 notifier::NotifierOptions invalidator_options; | 46 notifier::NotifierOptions invalidator_options; |
| 46 invalidator_options.request_context_getter = request_context_getter_; | 47 invalidator_options.request_context_getter = request_context_getter_; |
| 47 invalidator_.reset( | 48 invalidator_.reset( |
| 48 new NonBlockingInvalidator( | 49 new NonBlockingInvalidator( |
| 49 invalidator_options, | 50 invalidator_options, |
| 51 invalidator_client_id, |
| 50 InvalidationStateMap(), | 52 InvalidationStateMap(), |
| 51 initial_state, | 53 initial_state, |
| 52 MakeWeakHandle(invalidation_state_tracker), | 54 MakeWeakHandle(invalidation_state_tracker), |
| 53 "fake_client_info")); | 55 "fake_client_info")); |
| 54 } | 56 } |
| 55 | 57 |
| 56 Invalidator* GetInvalidator() { | 58 Invalidator* GetInvalidator() { |
| 57 return invalidator_.get(); | 59 return invalidator_.get(); |
| 58 } | 60 } |
| 59 | 61 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 scoped_ptr<NonBlockingInvalidator> invalidator_; | 93 scoped_ptr<NonBlockingInvalidator> invalidator_; |
| 92 }; | 94 }; |
| 93 | 95 |
| 94 INSTANTIATE_TYPED_TEST_CASE_P( | 96 INSTANTIATE_TYPED_TEST_CASE_P( |
| 95 NonBlockingInvalidatorTest, InvalidatorTest, | 97 NonBlockingInvalidatorTest, InvalidatorTest, |
| 96 NonBlockingInvalidatorTestDelegate); | 98 NonBlockingInvalidatorTestDelegate); |
| 97 | 99 |
| 98 } // namespace | 100 } // namespace |
| 99 | 101 |
| 100 } // namespace syncer | 102 } // namespace syncer |
| OLD | NEW |