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

Side by Side Diff: chrome/browser/sync/notifier/chrome_invalidation_client.cc

Issue 2827014: Implemented initial version of server-issued notification client. (Closed)
Patch Set: Added DEPS Created 10 years, 6 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
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/notifier/chrome_invalidation_client.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/logging.h"
11 #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h"
12 #include "chrome/browser/sync/notifier/invalidation_util.h"
13 #include "google/cacheinvalidation/invalidation-client-impl.h"
14
15 namespace sync_notifier {
16
17 ChromeInvalidationClient::ChromeInvalidationClient() {
18 DCHECK(non_thread_safe_.CalledOnValidThread());
19 }
20
21 ChromeInvalidationClient::~ChromeInvalidationClient() {
22 DCHECK(non_thread_safe_.CalledOnValidThread());
23 Stop();
24 }
25
26 void ChromeInvalidationClient::Start(
27 const std::string& app_name,
28 invalidation::InvalidationListener* listener,
29 buzz::XmppClient* xmpp_client) {
30 DCHECK(non_thread_safe_.CalledOnValidThread());
31 Stop();
32
33 chrome_system_resources_.StartScheduler();
34
35 invalidation::ClientType client_type;
36 client_type.set_type(invalidation::ClientType::CHROME_SYNC);
37 invalidation::ClientConfig ticl_config;
38 invalidation_client_.reset(
39 new invalidation::InvalidationClientImpl(
40 &chrome_system_resources_, client_type, app_name, listener,
41 ticl_config));
42 cache_invalidation_packet_handler_.reset(
43 new CacheInvalidationPacketHandler(xmpp_client,
44 invalidation_client_.get()));
45 }
46
47 void ChromeInvalidationClient::Stop() {
48 DCHECK(non_thread_safe_.CalledOnValidThread());
49 if (!invalidation_client_.get()) {
50 DCHECK(!cache_invalidation_packet_handler_.get());
51 return;
52 }
53
54 chrome_system_resources_.StopScheduler();
55
56 cache_invalidation_packet_handler_.reset();
57 invalidation_client_.reset();
58 }
59
60 void ChromeInvalidationClient::Register(
61 const invalidation::ObjectId& oid,
62 invalidation::RegistrationCallback* callback) {
63 DCHECK(non_thread_safe_.CalledOnValidThread());
64 invalidation_client_->Register(oid, callback);
65 }
66
67 void ChromeInvalidationClient::Unregister(
68 const invalidation::ObjectId& oid,
69 invalidation::RegistrationCallback* callback) {
70 DCHECK(non_thread_safe_.CalledOnValidThread());
71 invalidation_client_->Unregister(oid, callback);
72 }
73
74 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/chrome_invalidation_client.h ('k') | chrome/browser/sync/notifier/chrome_system_resources.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698