| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/sync/notifier/chrome_invalidation_client.h" | 5 #include "chrome/browser/sync/notifier/chrome_invalidation_client.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" | 11 #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" |
| 12 #include "chrome/browser/sync/notifier/invalidation_util.h" | 12 #include "chrome/browser/sync/notifier/invalidation_util.h" |
| 13 #include "google/cacheinvalidation/invalidation-client-impl.h" | |
| 14 | 13 |
| 15 namespace sync_notifier { | 14 namespace sync_notifier { |
| 16 | 15 |
| 17 ChromeInvalidationClient::ChromeInvalidationClient() { | 16 ChromeInvalidationClient::ChromeInvalidationClient() { |
| 18 DCHECK(non_thread_safe_.CalledOnValidThread()); | 17 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 19 } | 18 } |
| 20 | 19 |
| 21 ChromeInvalidationClient::~ChromeInvalidationClient() { | 20 ChromeInvalidationClient::~ChromeInvalidationClient() { |
| 22 DCHECK(non_thread_safe_.CalledOnValidThread()); | 21 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 23 Stop(); | 22 Stop(); |
| 24 } | 23 } |
| 25 | 24 |
| 26 void ChromeInvalidationClient::Start( | 25 void ChromeInvalidationClient::Start( |
| 27 const std::string& app_name, | 26 const std::string& client_id, |
| 28 invalidation::InvalidationListener* listener, | 27 invalidation::InvalidationListener* listener, |
| 29 buzz::XmppClient* xmpp_client) { | 28 buzz::XmppClient* xmpp_client) { |
| 30 DCHECK(non_thread_safe_.CalledOnValidThread()); | 29 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 31 Stop(); | 30 Stop(); |
| 32 | 31 |
| 33 chrome_system_resources_.StartScheduler(); | 32 chrome_system_resources_.StartScheduler(); |
| 34 | 33 |
| 35 invalidation::ClientType client_type; | 34 invalidation::ClientType client_type; |
| 36 client_type.set_type(invalidation::ClientType::CHROME_SYNC); | 35 client_type.set_type(invalidation::ClientType::CHROME_SYNC); |
| 37 invalidation::ClientConfig ticl_config; | |
| 38 invalidation_client_.reset( | 36 invalidation_client_.reset( |
| 39 new invalidation::InvalidationClientImpl( | 37 invalidation::InvalidationClient::Create( |
| 40 &chrome_system_resources_, client_type, app_name, listener, | 38 &chrome_system_resources_, client_type, client_id, listener)); |
| 41 ticl_config)); | |
| 42 cache_invalidation_packet_handler_.reset( | 39 cache_invalidation_packet_handler_.reset( |
| 43 new CacheInvalidationPacketHandler(xmpp_client, | 40 new CacheInvalidationPacketHandler(xmpp_client, |
| 44 invalidation_client_.get())); | 41 invalidation_client_.get())); |
| 45 } | 42 } |
| 46 | 43 |
| 47 void ChromeInvalidationClient::Stop() { | 44 void ChromeInvalidationClient::Stop() { |
| 48 DCHECK(non_thread_safe_.CalledOnValidThread()); | 45 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 49 if (!invalidation_client_.get()) { | 46 if (!invalidation_client_.get()) { |
| 50 DCHECK(!cache_invalidation_packet_handler_.get()); | 47 DCHECK(!cache_invalidation_packet_handler_.get()); |
| 51 return; | 48 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 65 } | 62 } |
| 66 | 63 |
| 67 void ChromeInvalidationClient::Unregister( | 64 void ChromeInvalidationClient::Unregister( |
| 68 const invalidation::ObjectId& oid, | 65 const invalidation::ObjectId& oid, |
| 69 invalidation::RegistrationCallback* callback) { | 66 invalidation::RegistrationCallback* callback) { |
| 70 DCHECK(non_thread_safe_.CalledOnValidThread()); | 67 DCHECK(non_thread_safe_.CalledOnValidThread()); |
| 71 invalidation_client_->Unregister(oid, callback); | 68 invalidation_client_->Unregister(oid, callback); |
| 72 } | 69 } |
| 73 | 70 |
| 74 } // namespace sync_notifier | 71 } // namespace sync_notifier |
| OLD | NEW |