| 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 "components/invalidation/invalidation_notifier.h" | 5 #include "components/invalidation/invalidation_notifier.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "components/invalidation/fake_invalidation_handler.h" | 9 #include "components/invalidation/fake_invalidation_handler.h" |
| 10 #include "components/invalidation/fake_invalidation_state_tracker.h" | 10 #include "components/invalidation/fake_invalidation_state_tracker.h" |
| 11 #include "components/invalidation/invalidation_state_tracker.h" | 11 #include "components/invalidation/invalidation_state_tracker.h" |
| 12 #include "components/invalidation/invalidator_test_template.h" | 12 #include "components/invalidation/invalidator_test_template.h" |
| 13 #include "components/invalidation/push_client_channel.h" | 13 #include "components/invalidation/push_client_channel.h" |
| 14 #include "jingle/notifier/base/fake_base_task.h" | 14 #include "jingle/notifier/base/fake_base_task.h" |
| 15 #include "jingle/notifier/base/notifier_options.h" | 15 #include "jingle/notifier/base/notifier_options.h" |
| 16 #include "jingle/notifier/listener/fake_push_client.h" | 16 #include "jingle/notifier/listener/fake_push_client.h" |
| 17 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 void CreateInvalidator( | 32 void CreateInvalidator( |
| 33 const std::string& invalidator_client_id, | 33 const std::string& invalidator_client_id, |
| 34 const std::string& initial_state, | 34 const std::string& initial_state, |
| 35 const base::WeakPtr<InvalidationStateTracker>& | 35 const base::WeakPtr<InvalidationStateTracker>& |
| 36 invalidation_state_tracker) { | 36 invalidation_state_tracker) { |
| 37 DCHECK(!invalidator_.get()); | 37 DCHECK(!invalidator_.get()); |
| 38 scoped_ptr<notifier::PushClient> push_client( | 38 scoped_ptr<notifier::PushClient> push_client( |
| 39 new notifier::FakePushClient()); | 39 new notifier::FakePushClient()); |
| 40 scoped_ptr<SyncNetworkChannel> network_channel( | 40 scoped_ptr<SyncNetworkChannel> network_channel( |
| 41 new PushClientChannel(push_client.Pass())); | 41 new PushClientChannel(push_client.Pass())); |
| 42 invalidator_.reset( | 42 invalidator_.reset(new InvalidationNotifier( |
| 43 new InvalidationNotifier(network_channel.Pass(), | 43 network_channel.Pass(), invalidator_client_id, |
| 44 invalidator_client_id, | 44 UnackedInvalidationsMap(), initial_state, invalidation_state_tracker, |
| 45 UnackedInvalidationsMap(), | 45 base::ThreadTaskRunnerHandle::Get(), "fake_client_info")); |
| 46 initial_state, | |
| 47 invalidation_state_tracker, | |
| 48 base::MessageLoopProxy::current(), | |
| 49 "fake_client_info")); | |
| 50 } | 46 } |
| 51 | 47 |
| 52 Invalidator* GetInvalidator() { | 48 Invalidator* GetInvalidator() { |
| 53 return invalidator_.get(); | 49 return invalidator_.get(); |
| 54 } | 50 } |
| 55 | 51 |
| 56 void DestroyInvalidator() { | 52 void DestroyInvalidator() { |
| 57 // Stopping the invalidation notifier stops its scheduler, which deletes | 53 // Stopping the invalidation notifier stops its scheduler, which deletes |
| 58 // any pending tasks without running them. Some tasks "run and delete" | 54 // any pending tasks without running them. Some tasks "run and delete" |
| 59 // another task, so they must be run in order to avoid leaking the inner | 55 // another task, so they must be run in order to avoid leaking the inner |
| (...skipping 21 matching lines...) Expand all Loading... |
| 81 scoped_ptr<InvalidationNotifier> invalidator_; | 77 scoped_ptr<InvalidationNotifier> invalidator_; |
| 82 }; | 78 }; |
| 83 | 79 |
| 84 INSTANTIATE_TYPED_TEST_CASE_P( | 80 INSTANTIATE_TYPED_TEST_CASE_P( |
| 85 InvalidationNotifierTest, InvalidatorTest, | 81 InvalidationNotifierTest, InvalidatorTest, |
| 86 InvalidationNotifierTestDelegate); | 82 InvalidationNotifierTestDelegate); |
| 87 | 83 |
| 88 } // namespace | 84 } // namespace |
| 89 | 85 |
| 90 } // namespace syncer | 86 } // namespace syncer |
| OLD | NEW |