| 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/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "google/cacheinvalidation/types.pb.h" | 12 #include "google/cacheinvalidation/types.pb.h" |
| 13 #include "jingle/notifier/base/fake_base_task.h" | 13 #include "jingle/notifier/base/fake_base_task.h" |
| 14 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
| 15 #include "sync/internal_api/public/util/weak_handle.h" | 15 #include "sync/internal_api/public/util/weak_handle.h" |
| 16 #include "sync/notifier/fake_invalidation_handler.h" | 16 #include "sync/notifier/fake_invalidation_handler.h" |
| 17 #include "sync/notifier/invalidation_state_tracker.h" | 17 #include "sync/notifier/invalidation_state_tracker.h" |
| 18 #include "sync/notifier/invalidator_test_template.h" | 18 #include "sync/notifier/invalidator_test_template.h" |
| 19 #include "sync/notifier/object_id_state_map_test_util.h" | 19 #include "sync/notifier/object_id_invalidation_map_test_util.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 namespace syncer { | 22 namespace syncer { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Needed by WaitForInvalidator(). | 26 // Needed by WaitForInvalidator(). |
| 27 void DoNothing() {} | 27 void DoNothing() {} |
| 28 | 28 |
| 29 class NonBlockingInvalidatorTestDelegate { | 29 class NonBlockingInvalidatorTestDelegate { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 FROM_HERE, | 73 FROM_HERE, |
| 74 base::Bind(&DoNothing), | 74 base::Bind(&DoNothing), |
| 75 run_loop.QuitClosure())); | 75 run_loop.QuitClosure())); |
| 76 run_loop.Run(); | 76 run_loop.Run(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void TriggerOnInvalidatorStateChange(InvalidatorState state) { | 79 void TriggerOnInvalidatorStateChange(InvalidatorState state) { |
| 80 invalidator_->OnInvalidatorStateChange(state); | 80 invalidator_->OnInvalidatorStateChange(state); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void TriggerOnIncomingInvalidation(const ObjectIdStateMap& id_state_map, | 83 void TriggerOnIncomingInvalidation( |
| 84 IncomingInvalidationSource source) { | 84 const ObjectIdInvalidationMap& invalidation_map, |
| 85 invalidator_->OnIncomingInvalidation(id_state_map, source); | 85 IncomingInvalidationSource source) { |
| 86 invalidator_->OnIncomingInvalidation(invalidation_map, source); |
| 86 } | 87 } |
| 87 | 88 |
| 88 static bool InvalidatorHandlesDeprecatedState() { | 89 static bool InvalidatorHandlesDeprecatedState() { |
| 89 return true; | 90 return true; |
| 90 } | 91 } |
| 91 | 92 |
| 92 private: | 93 private: |
| 93 MessageLoop message_loop_; | 94 MessageLoop message_loop_; |
| 94 base::Thread io_thread_; | 95 base::Thread io_thread_; |
| 95 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 96 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 96 scoped_ptr<NonBlockingInvalidator> invalidator_; | 97 scoped_ptr<NonBlockingInvalidator> invalidator_; |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 INSTANTIATE_TYPED_TEST_CASE_P( | 100 INSTANTIATE_TYPED_TEST_CASE_P( |
| 100 NonBlockingInvalidatorTest, InvalidatorTest, | 101 NonBlockingInvalidatorTest, InvalidatorTest, |
| 101 NonBlockingInvalidatorTestDelegate); | 102 NonBlockingInvalidatorTestDelegate); |
| 102 | 103 |
| 103 } // namespace | 104 } // namespace |
| 104 | 105 |
| 105 } // namespace syncer | 106 } // namespace syncer |
| OLD | NEW |