| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const char kHostPortSwitch[] = "host-port"; | 47 const char kHostPortSwitch[] = "host-port"; |
| 48 const char kTrySslTcpFirstSwitch[] = "try-ssltcp-first"; | 48 const char kTrySslTcpFirstSwitch[] = "try-ssltcp-first"; |
| 49 const char kAllowInsecureConnectionSwitch[] = "allow-insecure-connection"; | 49 const char kAllowInsecureConnectionSwitch[] = "allow-insecure-connection"; |
| 50 | 50 |
| 51 // Class to print received notifications events. | 51 // Class to print received notifications events. |
| 52 class NotificationPrinter : public InvalidationHandler { | 52 class NotificationPrinter : public InvalidationHandler { |
| 53 public: | 53 public: |
| 54 NotificationPrinter() {} | 54 NotificationPrinter() {} |
| 55 virtual ~NotificationPrinter() {} | 55 virtual ~NotificationPrinter() {} |
| 56 | 56 |
| 57 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE { | 57 virtual void OnInvalidatorStateChange(InvalidatorState state) override { |
| 58 LOG(INFO) << "Invalidator state changed to " | 58 LOG(INFO) << "Invalidator state changed to " |
| 59 << InvalidatorStateToString(state); | 59 << InvalidatorStateToString(state); |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual void OnIncomingInvalidation( | 62 virtual void OnIncomingInvalidation( |
| 63 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE { | 63 const ObjectIdInvalidationMap& invalidation_map) override { |
| 64 ObjectIdSet ids = invalidation_map.GetObjectIds(); | 64 ObjectIdSet ids = invalidation_map.GetObjectIds(); |
| 65 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { | 65 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { |
| 66 LOG(INFO) << "Remote invalidation: " | 66 LOG(INFO) << "Remote invalidation: " |
| 67 << invalidation_map.ToString(); | 67 << invalidation_map.ToString(); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual std::string GetOwnerName() const OVERRIDE { | 71 virtual std::string GetOwnerName() const override { |
| 72 return "NotificationPrinter"; | 72 return "NotificationPrinter"; |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(NotificationPrinter); | 76 DISALLOW_COPY_AND_ASSIGN(NotificationPrinter); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // Needed to use a real host resolver. | 79 // Needed to use a real host resolver. |
| 80 class MyTestURLRequestContext : public net::TestURLRequestContext { | 80 class MyTestURLRequestContext : public net::TestURLRequestContext { |
| 81 public: | 81 public: |
| 82 MyTestURLRequestContext() : TestURLRequestContext(true) { | 82 MyTestURLRequestContext() : TestURLRequestContext(true) { |
| 83 context_storage_.set_host_resolver( | 83 context_storage_.set_host_resolver( |
| 84 net::HostResolver::CreateDefaultResolver(NULL)); | 84 net::HostResolver::CreateDefaultResolver(NULL)); |
| 85 context_storage_.set_transport_security_state( | 85 context_storage_.set_transport_security_state( |
| 86 new net::TransportSecurityState()); | 86 new net::TransportSecurityState()); |
| 87 Init(); | 87 Init(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 virtual ~MyTestURLRequestContext() {} | 90 virtual ~MyTestURLRequestContext() {} |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 class MyTestURLRequestContextGetter : public net::TestURLRequestContextGetter { | 93 class MyTestURLRequestContextGetter : public net::TestURLRequestContextGetter { |
| 94 public: | 94 public: |
| 95 explicit MyTestURLRequestContextGetter( | 95 explicit MyTestURLRequestContextGetter( |
| 96 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) | 96 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) |
| 97 : TestURLRequestContextGetter(io_task_runner) {} | 97 : TestURLRequestContextGetter(io_task_runner) {} |
| 98 | 98 |
| 99 virtual net::TestURLRequestContext* GetURLRequestContext() OVERRIDE { | 99 virtual net::TestURLRequestContext* GetURLRequestContext() override { |
| 100 // Construct |context_| lazily so it gets constructed on the right | 100 // Construct |context_| lazily so it gets constructed on the right |
| 101 // thread (the IO thread). | 101 // thread (the IO thread). |
| 102 if (!context_) | 102 if (!context_) |
| 103 context_.reset(new MyTestURLRequestContext()); | 103 context_.reset(new MyTestURLRequestContext()); |
| 104 return context_.get(); | 104 return context_.get(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 virtual ~MyTestURLRequestContextGetter() {} | 108 virtual ~MyTestURLRequestContextGetter() {} |
| 109 | 109 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 io_thread.Stop(); | 212 io_thread.Stop(); |
| 213 return 0; | 213 return 0; |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace | 216 } // namespace |
| 217 } // namespace syncer | 217 } // namespace syncer |
| 218 | 218 |
| 219 int main(int argc, char* argv[]) { | 219 int main(int argc, char* argv[]) { |
| 220 return syncer::SyncListenNotificationsMain(argc, argv); | 220 return syncer::SyncListenNotificationsMain(argc, argv); |
| 221 } | 221 } |
| OLD | NEW |