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 <cstddef> | 5 #include <cstddef> |
6 #include <cstdio> | 6 #include <cstdio> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/base64.h" | |
11 #include "base/command_line.h" | 10 #include "base/command_line.h" |
12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | |
17 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
18 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
19 #include "jingle/notifier/base/notification_method.h" | 17 #include "jingle/notifier/base/notification_method.h" |
20 #include "jingle/notifier/base/notifier_options.h" | 18 #include "jingle/notifier/base/notifier_options.h" |
21 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
22 #include "net/base/host_resolver.h" | 20 #include "net/base/host_resolver.h" |
23 #include "net/base/network_change_notifier.h" | 21 #include "net/base/network_change_notifier.h" |
24 #include "net/base/transport_security_state.h" | 22 #include "net/base/transport_security_state.h" |
25 #include "net/url_request/url_request_test_util.h" | 23 #include "net/url_request/url_request_test_util.h" |
26 #include "sync/internal_api/public/base/model_type.h" | 24 #include "sync/internal_api/public/base/model_type.h" |
27 #include "sync/internal_api/public/base/model_type_invalidation_map.h" | 25 #include "sync/internal_api/public/base/model_type_invalidation_map.h" |
28 #include "sync/notifier/invalidation_state_tracker.h" | 26 #include "sync/notifier/invalidation_state_tracker.h" |
29 #include "sync/notifier/invalidation_handler.h" | 27 #include "sync/notifier/invalidation_handler.h" |
30 #include "sync/notifier/invalidation_util.h" | 28 #include "sync/notifier/invalidation_util.h" |
31 #include "sync/notifier/invalidator_factory.h" | 29 #include "sync/notifier/invalidator_factory.h" |
32 #include "sync/notifier/invalidator.h" | 30 #include "sync/notifier/invalidator.h" |
| 31 #include "sync/tools/null_invalidation_state_tracker.h" |
33 | 32 |
34 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
35 #include "base/mac/scoped_nsautorelease_pool.h" | 34 #include "base/mac/scoped_nsautorelease_pool.h" |
36 #endif | 35 #endif |
37 | 36 |
38 // This is a simple utility that initializes a sync notifier and | 37 // This is a simple utility that initializes a sync notifier and |
39 // listens to any received notifications. | 38 // listens to any received notifications. |
40 | 39 |
41 namespace syncer { | 40 namespace syncer { |
42 namespace { | 41 namespace { |
(...skipping 28 matching lines...) Expand all Loading... |
71 << " Invalidation: type = " | 70 << " Invalidation: type = " |
72 << ModelTypeToString(it->first) | 71 << ModelTypeToString(it->first) |
73 << ", payload = " << it->second.payload; | 72 << ", payload = " << it->second.payload; |
74 } | 73 } |
75 } | 74 } |
76 | 75 |
77 private: | 76 private: |
78 DISALLOW_COPY_AND_ASSIGN(NotificationPrinter); | 77 DISALLOW_COPY_AND_ASSIGN(NotificationPrinter); |
79 }; | 78 }; |
80 | 79 |
81 class NullInvalidationStateTracker | |
82 : public base::SupportsWeakPtr<NullInvalidationStateTracker>, | |
83 public InvalidationStateTracker { | |
84 public: | |
85 NullInvalidationStateTracker() {} | |
86 virtual ~NullInvalidationStateTracker() {} | |
87 | |
88 virtual InvalidationStateMap GetAllInvalidationStates() const OVERRIDE { | |
89 return InvalidationStateMap(); | |
90 } | |
91 | |
92 virtual void SetMaxVersion( | |
93 const invalidation::ObjectId& id, | |
94 int64 max_invalidation_version) OVERRIDE { | |
95 LOG(INFO) << "Setting max invalidation version for " | |
96 << ObjectIdToString(id) << " to " << max_invalidation_version; | |
97 } | |
98 | |
99 virtual void Forget(const ObjectIdSet& ids) OVERRIDE { | |
100 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { | |
101 LOG(INFO) << "Forgetting saved state for " << ObjectIdToString(*it); | |
102 } | |
103 } | |
104 | |
105 virtual std::string GetBootstrapData() const OVERRIDE { | |
106 return std::string(); | |
107 } | |
108 | |
109 virtual void SetBootstrapData(const std::string& data) OVERRIDE { | |
110 std::string base64_data; | |
111 CHECK(base::Base64Encode(data, &base64_data)); | |
112 LOG(INFO) << "Setting bootstrap data to: " << base64_data; | |
113 } | |
114 }; | |
115 | |
116 // Needed to use a real host resolver. | 80 // Needed to use a real host resolver. |
117 class MyTestURLRequestContext : public net::TestURLRequestContext { | 81 class MyTestURLRequestContext : public net::TestURLRequestContext { |
118 public: | 82 public: |
119 MyTestURLRequestContext() : TestURLRequestContext(true) { | 83 MyTestURLRequestContext() : TestURLRequestContext(true) { |
120 context_storage_.set_host_resolver( | 84 context_storage_.set_host_resolver( |
121 net::HostResolver::CreateDefaultResolver(NULL)); | 85 net::HostResolver::CreateDefaultResolver(NULL)); |
122 context_storage_.set_transport_security_state( | 86 context_storage_.set_transport_security_state( |
123 new net::TransportSecurityState()); | 87 new net::TransportSecurityState()); |
124 Init(); | 88 Init(); |
125 } | 89 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 io_thread.Stop(); | 218 io_thread.Stop(); |
255 return 0; | 219 return 0; |
256 } | 220 } |
257 | 221 |
258 } // namespace | 222 } // namespace |
259 } // namespace syncer | 223 } // namespace syncer |
260 | 224 |
261 int main(int argc, char* argv[]) { | 225 int main(int argc, char* argv[]) { |
262 return syncer::SyncListenNotificationsMain(argc, argv); | 226 return syncer::SyncListenNotificationsMain(argc, argv); |
263 } | 227 } |
OLD | NEW |