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/debug/stack_trace.h" | 12 #include "base/debug/stack_trace.h" |
14 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
15 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
16 #include "base/logging.h" | 15 #include "base/logging.h" |
17 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
20 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
(...skipping 16 matching lines...) Expand all Loading... |
37 #include "sync/internal_api/public/sync_manager_factory.h" | 36 #include "sync/internal_api/public/sync_manager_factory.h" |
38 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 37 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
39 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 38 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
40 #include "sync/internal_api/public/util/weak_handle.h" | 39 #include "sync/internal_api/public/util/weak_handle.h" |
41 #include "sync/js/js_event_details.h" | 40 #include "sync/js/js_event_details.h" |
42 #include "sync/js/js_event_handler.h" | 41 #include "sync/js/js_event_handler.h" |
43 #include "sync/notifier/invalidation_state_tracker.h" | 42 #include "sync/notifier/invalidation_state_tracker.h" |
44 #include "sync/notifier/invalidator.h" | 43 #include "sync/notifier/invalidator.h" |
45 #include "sync/notifier/invalidator_factory.h" | 44 #include "sync/notifier/invalidator_factory.h" |
46 #include "sync/test/fake_encryptor.h" | 45 #include "sync/test/fake_encryptor.h" |
| 46 #include "sync/tools/null_invalidation_state_tracker.h" |
47 | 47 |
48 #if defined(OS_MACOSX) | 48 #if defined(OS_MACOSX) |
49 #include "base/mac/scoped_nsautorelease_pool.h" | 49 #include "base/mac/scoped_nsautorelease_pool.h" |
50 #endif | 50 #endif |
51 | 51 |
52 // This is a simple utility that initializes a sync client and | 52 // This is a simple utility that initializes a sync client and |
53 // prints out any events. | 53 // prints out any events. |
54 | 54 |
55 // TODO(akalin): Refactor to combine shared code with | 55 // TODO(akalin): Refactor to combine shared code with |
56 // sync_listen_notifications. | 56 // sync_listen_notifications. |
57 namespace syncer { | 57 namespace syncer { |
58 namespace { | 58 namespace { |
59 | 59 |
60 const char kEmailSwitch[] = "email"; | 60 const char kEmailSwitch[] = "email"; |
61 const char kTokenSwitch[] = "token"; | 61 const char kTokenSwitch[] = "token"; |
62 const char kXmppHostPortSwitch[] = "xmpp-host-port"; | 62 const char kXmppHostPortSwitch[] = "xmpp-host-port"; |
63 const char kXmppTrySslTcpFirstSwitch[] = "xmpp-try-ssltcp-first"; | 63 const char kXmppTrySslTcpFirstSwitch[] = "xmpp-try-ssltcp-first"; |
64 const char kXmppAllowInsecureConnectionSwitch[] = | 64 const char kXmppAllowInsecureConnectionSwitch[] = |
65 "xmpp-allow-insecure-connection"; | 65 "xmpp-allow-insecure-connection"; |
66 const char kNotificationMethodSwitch[] = "notification-method"; | 66 const char kNotificationMethodSwitch[] = "notification-method"; |
67 | 67 |
68 class NullInvalidationStateTracker | |
69 : public base::SupportsWeakPtr<NullInvalidationStateTracker>, | |
70 public InvalidationStateTracker { | |
71 public: | |
72 NullInvalidationStateTracker() {} | |
73 virtual ~NullInvalidationStateTracker() {} | |
74 | |
75 virtual InvalidationStateMap GetAllInvalidationStates() const OVERRIDE { | |
76 return InvalidationStateMap(); | |
77 } | |
78 | |
79 virtual void SetMaxVersion( | |
80 const invalidation::ObjectId& id, | |
81 int64 max_invalidation_version) OVERRIDE { | |
82 VLOG(1) << "Setting max invalidation version for " | |
83 << ObjectIdToString(id) << " to " << max_invalidation_version; | |
84 } | |
85 | |
86 virtual void Forget(const ObjectIdSet& ids) OVERRIDE { | |
87 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { | |
88 VLOG(1) << "Forgetting invalidation state for " << ObjectIdToString(*it); | |
89 } | |
90 } | |
91 | |
92 virtual std::string GetBootstrapData() const OVERRIDE { | |
93 return std::string(); | |
94 } | |
95 | |
96 virtual void SetBootstrapData(const std::string& data) OVERRIDE { | |
97 std::string base64_data; | |
98 CHECK(base::Base64Encode(data, &base64_data)); | |
99 VLOG(1) << "Setting bootstrap data to: " << base64_data; | |
100 } | |
101 }; | |
102 | |
103 // Needed to use a real host resolver. | 68 // Needed to use a real host resolver. |
104 class MyTestURLRequestContext : public net::TestURLRequestContext { | 69 class MyTestURLRequestContext : public net::TestURLRequestContext { |
105 public: | 70 public: |
106 MyTestURLRequestContext() : TestURLRequestContext(true) { | 71 MyTestURLRequestContext() : TestURLRequestContext(true) { |
107 context_storage_.set_host_resolver( | 72 context_storage_.set_host_resolver( |
108 net::HostResolver::CreateDefaultResolver(NULL)); | 73 net::HostResolver::CreateDefaultResolver(NULL)); |
109 context_storage_.set_transport_security_state( | 74 context_storage_.set_transport_security_state( |
110 new net::TransportSecurityState()); | 75 new net::TransportSecurityState()); |
111 Init(); | 76 Init(); |
112 } | 77 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 io_thread.Stop(); | 355 io_thread.Stop(); |
391 return 0; | 356 return 0; |
392 } | 357 } |
393 | 358 |
394 } // namespace | 359 } // namespace |
395 } // namespace syncer | 360 } // namespace syncer |
396 | 361 |
397 int main(int argc, char* argv[]) { | 362 int main(int argc, char* argv[]) { |
398 return syncer::SyncClientMain(argc, argv); | 363 return syncer::SyncClientMain(argc, argv); |
399 } | 364 } |
OLD | NEW |