Revert 282130 "Adds API test for imageWriterPrivate.writeFromFile"
[chromium-blink-merge.git] / components / invalidation / p2p_invalidation_service.cc
blobb24625b0c7179d95c9d10edd7cf0300865e4ec89
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.
5 #include "components/invalidation/p2p_invalidation_service.h"
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"
15 namespace net {
16 class URLRequestContextGetter;
19 namespace invalidation {
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(*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));
36 P2PInvalidationService::~P2PInvalidationService() {
39 void P2PInvalidationService::UpdateCredentials(const std::string& username,
40 const std::string& password) {
41 invalidator_->UpdateCredentials(username, password);
44 void P2PInvalidationService::RegisterInvalidationHandler(
45 syncer::InvalidationHandler* handler) {
46 invalidator_->RegisterHandler(handler);
49 void P2PInvalidationService::UpdateRegisteredInvalidationIds(
50 syncer::InvalidationHandler* handler,
51 const syncer::ObjectIdSet& ids) {
52 invalidator_->UpdateRegisteredIds(handler, ids);
55 void P2PInvalidationService::UnregisterInvalidationHandler(
56 syncer::InvalidationHandler* handler) {
57 invalidator_->UnregisterHandler(handler);
60 void P2PInvalidationService::SendInvalidation(
61 const syncer::ObjectIdSet& ids) {
62 invalidator_->SendInvalidation(ids);
65 syncer::InvalidatorState P2PInvalidationService::GetInvalidatorState() const {
66 return invalidator_->GetInvalidatorState();
69 std::string P2PInvalidationService::GetInvalidatorClientId() const {
70 return invalidator_id_;
73 InvalidationLogger* P2PInvalidationService::GetInvalidationLogger() {
74 return NULL;
77 void P2PInvalidationService::RequestDetailedStatus(
78 base::Callback<void(const base::DictionaryValue&)> caller) const {
79 base::DictionaryValue value;
80 caller.Run(value);
83 IdentityProvider* P2PInvalidationService::GetIdentityProvider() {
84 return identity_provider_.get();
87 } // namespace invalidation