OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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/invalidation/p2p_invalidation_service.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/invalidation/invalidation_service_util.h" |
| 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "jingle/notifier/base/notifier_options.h" |
| 12 #include "jingle/notifier/listener/push_client.h" |
| 13 #include "sync/notifier/p2p_invalidator.h" |
| 14 |
| 15 namespace net { |
| 16 class URLRequestContextGetter; |
| 17 } |
| 18 |
| 19 namespace invalidation { |
| 20 |
| 21 P2PInvalidationService::P2PInvalidationService(Profile* profile) { |
| 22 notifier::NotifierOptions notifier_options = |
| 23 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); |
| 24 notifier_options.request_context_getter = profile->GetRequestContext(); |
| 25 invalidator_id_ = GenerateInvalidatorClientId(); |
| 26 invalidator_.reset(new syncer::P2PInvalidator( |
| 27 notifier::PushClient::CreateDefault(notifier_options), |
| 28 invalidator_id_, |
| 29 syncer::NOTIFY_ALL)); |
| 30 } |
| 31 |
| 32 P2PInvalidationService::~P2PInvalidationService() { |
| 33 } |
| 34 |
| 35 void P2PInvalidationService::UpdateCredentials(const std::string& username, |
| 36 const std::string& password) { |
| 37 invalidator_->UpdateCredentials(username, password); |
| 38 } |
| 39 |
| 40 void P2PInvalidationService::Shutdown() { |
| 41 invalidator_.reset(); |
| 42 } |
| 43 |
| 44 void P2PInvalidationService::RegisterInvalidationHandler( |
| 45 syncer::InvalidationHandler* handler) { |
| 46 invalidator_->RegisterHandler(handler); |
| 47 } |
| 48 |
| 49 void P2PInvalidationService::UpdateRegisteredInvalidationIds( |
| 50 syncer::InvalidationHandler* handler, |
| 51 const syncer::ObjectIdSet& ids) { |
| 52 invalidator_->UpdateRegisteredIds(handler, ids); |
| 53 } |
| 54 |
| 55 void P2PInvalidationService::UnregisterInvalidationHandler( |
| 56 syncer::InvalidationHandler* handler) { |
| 57 invalidator_->UnregisterHandler(handler); |
| 58 } |
| 59 |
| 60 void P2PInvalidationService::AcknowledgeInvalidation( |
| 61 const invalidation::ObjectId& id, |
| 62 const syncer::AckHandle& ack_handle) { |
| 63 invalidator_->Acknowledge(id, ack_handle); |
| 64 } |
| 65 |
| 66 void P2PInvalidationService::SendInvalidation( |
| 67 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
| 68 invalidator_->SendInvalidation(invalidation_map); |
| 69 } |
| 70 |
| 71 syncer::InvalidatorState P2PInvalidationService::GetInvalidatorState() const { |
| 72 return invalidator_->GetInvalidatorState(); |
| 73 } |
| 74 |
| 75 std::string P2PInvalidationService::GetInvalidatorClientId() const { |
| 76 return invalidator_id_; |
| 77 } |
| 78 |
| 79 } // namespace invalidation |
OLD | NEW |