OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <cstdio> | 5 #include <cstdio> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
17 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" | 17 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" |
18 #include "chrome/browser/sync/notifier/sync_notifier.h" | 18 #include "chrome/browser/sync/notifier/sync_notifier.h" |
19 #include "chrome/browser/sync/notifier/sync_notifier_factory.h" | 19 #include "chrome/browser/sync/notifier/sync_notifier_factory.h" |
20 #include "chrome/browser/sync/notifier/sync_notifier_observer.h" | 20 #include "chrome/browser/sync/notifier/sync_notifier_observer.h" |
21 #include "chrome/browser/sync/syncable/model_type.h" | 21 #include "chrome/browser/sync/syncable/model_type.h" |
22 #include "chrome/browser/sync/syncable/model_type_payload_map.h" | 22 #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
23 #include "chrome/test/base/test_url_request_context_getter.h" | 23 #include "chrome/test/base/test_url_request_context_getter.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 | 25 |
| 26 using content::BrowserThread; |
| 27 |
26 // This is a simple utility that initializes a sync notifier and | 28 // This is a simple utility that initializes a sync notifier and |
27 // listens to any received notifications. | 29 // listens to any received notifications. |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 // Class to print received notifications events. | 33 // Class to print received notifications events. |
32 class NotificationPrinter : public sync_notifier::SyncNotifierObserver { | 34 class NotificationPrinter : public sync_notifier::SyncNotifierObserver { |
33 public: | 35 public: |
34 NotificationPrinter() {} | 36 NotificationPrinter() {} |
35 virtual ~NotificationPrinter() {} | 37 virtual ~NotificationPrinter() {} |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 base::AtExitManager exit_manager; | 88 base::AtExitManager exit_manager; |
87 CommandLine::Init(argc, argv); | 89 CommandLine::Init(argc, argv); |
88 logging::InitLogging( | 90 logging::InitLogging( |
89 NULL, | 91 NULL, |
90 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, | 92 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
91 logging::LOCK_LOG_FILE, | 93 logging::LOCK_LOG_FILE, |
92 logging::DELETE_OLD_LOG_FILE, | 94 logging::DELETE_OLD_LOG_FILE, |
93 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 95 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
94 | 96 |
95 MessageLoop ui_loop; | 97 MessageLoop ui_loop; |
96 DeprecatedBrowserThread ui_thread(BrowserThread::UI, &ui_loop); | 98 content::DeprecatedBrowserThread ui_thread(BrowserThread::UI, &ui_loop); |
97 | 99 |
98 DeprecatedBrowserThread io_thread(BrowserThread::IO); | 100 content::DeprecatedBrowserThread io_thread(BrowserThread::IO); |
99 base::Thread::Options options; | 101 base::Thread::Options options; |
100 options.message_loop_type = MessageLoop::TYPE_IO; | 102 options.message_loop_type = MessageLoop::TYPE_IO; |
101 io_thread.StartWithOptions(options); | 103 io_thread.StartWithOptions(options); |
102 | 104 |
103 // Parse command line. | 105 // Parse command line. |
104 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 106 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
105 std::string email = command_line.GetSwitchValueASCII("email"); | 107 std::string email = command_line.GetSwitchValueASCII("email"); |
106 std::string token = command_line.GetSwitchValueASCII("token"); | 108 std::string token = command_line.GetSwitchValueASCII("token"); |
107 // TODO(akalin): Write a wrapper script that gets a token for an | 109 // TODO(akalin): Write a wrapper script that gets a token for an |
108 // email and password and passes that in to this utility. | 110 // email and password and passes that in to this utility. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 144 } |
143 sync_notifier->UpdateEnabledTypes(types); | 145 sync_notifier->UpdateEnabledTypes(types); |
144 } | 146 } |
145 | 147 |
146 ui_loop.Run(); | 148 ui_loop.Run(); |
147 | 149 |
148 sync_notifier->RemoveObserver(¬ification_printer); | 150 sync_notifier->RemoveObserver(¬ification_printer); |
149 io_thread.Stop(); | 151 io_thread.Stop(); |
150 return 0; | 152 return 0; |
151 } | 153 } |
OLD | NEW |