| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 "components/invalidation/p2p_invalidation_service.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "components/invalidation/invalidation_service_util.h" | |
| 9 #include "components/invalidation/p2p_invalidator.h" | |
| 10 #include "google_apis/gaia/identity_provider.h" | |
| 11 #include "jingle/notifier/base/notifier_options.h" | |
| 12 #include "jingle/notifier/listener/push_client.h" | |
| 13 #include "net/url_request/url_request_context_getter.h" | |
| 14 | |
| 15 namespace net { | |
| 16 class URLRequestContextGetter; | |
| 17 } | |
| 18 | |
| 19 namespace invalidation { | |
| 20 | |
| 21 P2PInvalidationService::P2PInvalidationService( | |
| 22 scoped_ptr<IdentityProvider> identity_provider, | |
| 23 const scoped_refptr<net::URLRequestContextGetter>& request_context, | |
| 24 syncer::P2PNotificationTarget notification_target) | |
| 25 : identity_provider_(identity_provider.Pass()) { | |
| 26 notifier::NotifierOptions notifier_options = | |
| 27 ParseNotifierOptions(*base::CommandLine::ForCurrentProcess()); | |
| 28 notifier_options.request_context_getter = request_context; | |
| 29 invalidator_id_ = GenerateInvalidatorClientId(); | |
| 30 invalidator_.reset(new syncer::P2PInvalidator( | |
| 31 notifier::PushClient::CreateDefault(notifier_options), | |
| 32 invalidator_id_, | |
| 33 notification_target)); | |
| 34 } | |
| 35 | |
| 36 P2PInvalidationService::~P2PInvalidationService() { | |
| 37 } | |
| 38 | |
| 39 void P2PInvalidationService::UpdateCredentials(const std::string& username, | |
| 40 const std::string& password) { | |
| 41 invalidator_->UpdateCredentials(username, password); | |
| 42 } | |
| 43 | |
| 44 void P2PInvalidationService::RegisterInvalidationHandler( | |
| 45 syncer::InvalidationHandler* handler) { | |
| 46 invalidator_->RegisterHandler(handler); | |
| 47 } | |
| 48 | |
| 49 bool P2PInvalidationService::UpdateRegisteredInvalidationIds( | |
| 50 syncer::InvalidationHandler* handler, | |
| 51 const syncer::ObjectIdSet& ids) { | |
| 52 return invalidator_->UpdateRegisteredIds(handler, ids); | |
| 53 } | |
| 54 | |
| 55 void P2PInvalidationService::UnregisterInvalidationHandler( | |
| 56 syncer::InvalidationHandler* handler) { | |
| 57 invalidator_->UnregisterHandler(handler); | |
| 58 } | |
| 59 | |
| 60 void P2PInvalidationService::SendInvalidation( | |
| 61 const syncer::ObjectIdSet& ids) { | |
| 62 invalidator_->SendInvalidation(ids); | |
| 63 } | |
| 64 | |
| 65 syncer::InvalidatorState P2PInvalidationService::GetInvalidatorState() const { | |
| 66 return invalidator_->GetInvalidatorState(); | |
| 67 } | |
| 68 | |
| 69 std::string P2PInvalidationService::GetInvalidatorClientId() const { | |
| 70 return invalidator_id_; | |
| 71 } | |
| 72 | |
| 73 InvalidationLogger* P2PInvalidationService::GetInvalidationLogger() { | |
| 74 return NULL; | |
| 75 } | |
| 76 | |
| 77 void P2PInvalidationService::RequestDetailedStatus( | |
| 78 base::Callback<void(const base::DictionaryValue&)> caller) const { | |
| 79 base::DictionaryValue value; | |
| 80 caller.Run(value); | |
| 81 } | |
| 82 | |
| 83 IdentityProvider* P2PInvalidationService::GetIdentityProvider() { | |
| 84 return identity_provider_.get(); | |
| 85 } | |
| 86 | |
| 87 } // namespace invalidation | |
| OLD | NEW |