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

Side by Side Diff: chrome/browser/sync/tools/sync_listen_notifications.cc

Issue 9562037: Move TestURLRequestContextGetter to url_request_test_util.{h,cc} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change comment Created 8 years, 9 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
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 <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 "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" 18 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h"
19 #include "chrome/browser/sync/notifier/sync_notifier.h" 19 #include "chrome/browser/sync/notifier/sync_notifier.h"
20 #include "chrome/browser/sync/notifier/sync_notifier_factory.h" 20 #include "chrome/browser/sync/notifier/sync_notifier_factory.h"
21 #include "chrome/browser/sync/notifier/sync_notifier_observer.h" 21 #include "chrome/browser/sync/notifier/sync_notifier_observer.h"
22 #include "chrome/browser/sync/syncable/model_type.h" 22 #include "chrome/browser/sync/syncable/model_type.h"
23 #include "chrome/browser/sync/syncable/model_type_payload_map.h" 23 #include "chrome/browser/sync/syncable/model_type_payload_map.h"
24 #include "chrome/test/base/test_url_request_context_getter.h"
25 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
26 #include "content/test/test_browser_thread.h" 25 #include "content/test/test_browser_thread.h"
26 #include "net/url_request/url_request_test_util.h"
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
29 29
30 // This is a simple utility that initializes a sync notifier and 30 // This is a simple utility that initializes a sync notifier and
31 // listens to any received notifications. 31 // listens to any received notifications.
32 32
33 namespace { 33 namespace {
34 34
35 // Class to print received notifications events. 35 // Class to print received notifications events.
36 class NotificationPrinter : public sync_notifier::SyncNotifierObserver { 36 class NotificationPrinter : public sync_notifier::SyncNotifierObserver {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 "Run chrome and set a breakpoint on " 118 "Run chrome and set a breakpoint on "
119 "sync_api::SyncManager::SyncInternal::UpdateCredentials() " 119 "sync_api::SyncManager::SyncInternal::UpdateCredentials() "
120 "after logging into sync to get the token to pass into this " 120 "after logging into sync to get the token to pass into this "
121 "utility.\n", 121 "utility.\n",
122 argv[0]); 122 argv[0]);
123 return -1; 123 return -1;
124 } 124 }
125 125
126 const char kClientInfo[] = "sync_listen_notifications"; 126 const char kClientInfo[] = "sync_listen_notifications";
127 scoped_refptr<TestURLRequestContextGetter> request_context_getter( 127 scoped_refptr<TestURLRequestContextGetter> request_context_getter(
128 new TestURLRequestContextGetter()); 128 new TestURLRequestContextGetter(
129 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
129 NullInvalidationVersionTracker null_invalidation_version_tracker; 130 NullInvalidationVersionTracker null_invalidation_version_tracker;
130 sync_notifier::SyncNotifierFactory sync_notifier_factory( 131 sync_notifier::SyncNotifierFactory sync_notifier_factory(
131 kClientInfo, request_context_getter, 132 kClientInfo, request_context_getter,
132 null_invalidation_version_tracker.AsWeakPtr(), command_line); 133 null_invalidation_version_tracker.AsWeakPtr(), command_line);
133 scoped_ptr<sync_notifier::SyncNotifier> sync_notifier( 134 scoped_ptr<sync_notifier::SyncNotifier> sync_notifier(
134 sync_notifier_factory.CreateSyncNotifier()); 135 sync_notifier_factory.CreateSyncNotifier());
135 NotificationPrinter notification_printer; 136 NotificationPrinter notification_printer;
136 sync_notifier->AddObserver(&notification_printer); 137 sync_notifier->AddObserver(&notification_printer);
137 138
138 const char kUniqueId[] = "fake_unique_id"; 139 const char kUniqueId[] = "fake_unique_id";
139 sync_notifier->SetUniqueId(kUniqueId); 140 sync_notifier->SetUniqueId(kUniqueId);
140 sync_notifier->SetState(""); 141 sync_notifier->SetState("");
141 sync_notifier->UpdateCredentials(email, token); 142 sync_notifier->UpdateCredentials(email, token);
142 // Listen for notifications for all known types. 143 // Listen for notifications for all known types.
143 sync_notifier->UpdateEnabledTypes(syncable::ModelTypeSet::All()); 144 sync_notifier->UpdateEnabledTypes(syncable::ModelTypeSet::All());
144 145
145 ui_loop.Run(); 146 ui_loop.Run();
146 147
147 sync_notifier->RemoveObserver(&notification_printer); 148 sync_notifier->RemoveObserver(&notification_printer);
148 io_thread.Stop(); 149 io_thread.Stop();
149 return 0; 150 return 0;
150 } 151 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/sync_notifier_factory_unittest.cc ('k') | chrome/browser/sync/tools/sync_tools.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698