Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: sync/notifier/non_blocking_invalidator_unittest.cc

Issue 221963003: Reduce dependency of TiclInvalidationService on Profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync_listen_notifications. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/notifier/non_blocking_invalidator.cc ('k') | sync/tools/null_invalidation_state_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "google/cacheinvalidation/types.pb.h" 13 #include "google/cacheinvalidation/types.pb.h"
14 #include "jingle/notifier/base/fake_base_task.h" 14 #include "jingle/notifier/base/fake_base_task.h"
15 #include "net/url_request/url_request_test_util.h" 15 #include "net/url_request/url_request_test_util.h"
16 #include "sync/internal_api/public/util/weak_handle.h"
17 #include "sync/notifier/fake_invalidation_handler.h" 16 #include "sync/notifier/fake_invalidation_handler.h"
18 #include "sync/notifier/invalidation_state_tracker.h" 17 #include "sync/notifier/invalidation_state_tracker.h"
19 #include "sync/notifier/invalidator_test_template.h" 18 #include "sync/notifier/invalidator_test_template.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 20
22 namespace syncer { 21 namespace syncer {
23 22
24 namespace {
25
26 class NonBlockingInvalidatorTestDelegate { 23 class NonBlockingInvalidatorTestDelegate {
27 public: 24 public:
28 NonBlockingInvalidatorTestDelegate() : io_thread_("IO thread") {} 25 NonBlockingInvalidatorTestDelegate() : io_thread_("IO thread") {}
29 26
30 ~NonBlockingInvalidatorTestDelegate() { 27 ~NonBlockingInvalidatorTestDelegate() {
31 DestroyInvalidator(); 28 DestroyInvalidator();
32 } 29 }
33 30
34 void CreateInvalidator( 31 void CreateInvalidator(
35 const std::string& invalidator_client_id, 32 const std::string& invalidator_client_id,
36 const std::string& initial_state, 33 const std::string& initial_state,
37 const base::WeakPtr<InvalidationStateTracker>& 34 const base::WeakPtr<InvalidationStateTracker>&
38 invalidation_state_tracker) { 35 invalidation_state_tracker) {
39 DCHECK(!invalidator_.get()); 36 DCHECK(!invalidator_.get());
40 base::Thread::Options options; 37 base::Thread::Options options;
41 options.message_loop_type = base::MessageLoop::TYPE_IO; 38 options.message_loop_type = base::MessageLoop::TYPE_IO;
42 io_thread_.StartWithOptions(options); 39 io_thread_.StartWithOptions(options);
43 request_context_getter_ = 40 request_context_getter_ =
44 new net::TestURLRequestContextGetter(io_thread_.message_loop_proxy()); 41 new net::TestURLRequestContextGetter(io_thread_.message_loop_proxy());
45 notifier::NotifierOptions notifier_options; 42 notifier::NotifierOptions notifier_options;
46 notifier_options.request_context_getter = request_context_getter_; 43 notifier_options.request_context_getter = request_context_getter_;
47 NetworkChannelCreator network_channel_creator = 44 NetworkChannelCreator network_channel_creator =
48 NonBlockingInvalidator::MakePushClientChannelCreator(notifier_options); 45 NonBlockingInvalidator::MakePushClientChannelCreator(notifier_options);
49 invalidator_.reset( 46 invalidator_.reset(
50 new NonBlockingInvalidator( 47 new NonBlockingInvalidator(
51 network_channel_creator, 48 network_channel_creator,
52 invalidator_client_id, 49 invalidator_client_id,
53 UnackedInvalidationsMap(), 50 UnackedInvalidationsMap(),
54 initial_state, 51 initial_state,
55 MakeWeakHandle(invalidation_state_tracker), 52 invalidation_state_tracker.get(),
56 "fake_client_info", 53 "fake_client_info",
57 request_context_getter_)); 54 request_context_getter_));
58 } 55 }
59 56
60 Invalidator* GetInvalidator() { 57 Invalidator* GetInvalidator() {
61 return invalidator_.get(); 58 return invalidator_.get();
62 } 59 }
63 60
64 void DestroyInvalidator() { 61 void DestroyInvalidator() {
65 invalidator_.reset(); 62 invalidator_.reset();
(...skipping 25 matching lines...) Expand all
91 base::MessageLoop message_loop_; 88 base::MessageLoop message_loop_;
92 base::Thread io_thread_; 89 base::Thread io_thread_;
93 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 90 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
94 scoped_ptr<NonBlockingInvalidator> invalidator_; 91 scoped_ptr<NonBlockingInvalidator> invalidator_;
95 }; 92 };
96 93
97 INSTANTIATE_TYPED_TEST_CASE_P( 94 INSTANTIATE_TYPED_TEST_CASE_P(
98 NonBlockingInvalidatorTest, InvalidatorTest, 95 NonBlockingInvalidatorTest, InvalidatorTest,
99 NonBlockingInvalidatorTestDelegate); 96 NonBlockingInvalidatorTestDelegate);
100 97
101 } // namespace
102
103 } // namespace syncer 98 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/non_blocking_invalidator.cc ('k') | sync/tools/null_invalidation_state_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698