Make sure webrtc::VideoSource is released when WebRtcVideoTrackAdapter is destroyed.
[chromium-blink-merge.git] / components / invalidation / p2p_invalidation_service.cc
blob4eb98b6579b4058b4af366794f989d5827932365
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 "google_apis/gaia/identity_provider.h"
10 #include "jingle/notifier/base/notifier_options.h"
11 #include "jingle/notifier/listener/push_client.h"
12 #include "net/url_request/url_request_context_getter.h"
13 #include "sync/notifier/p2p_invalidator.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::Shutdown() {
45 invalidator_.reset();
48 void P2PInvalidationService::RegisterInvalidationHandler(
49 syncer::InvalidationHandler* handler) {
50 invalidator_->RegisterHandler(handler);
53 void P2PInvalidationService::UpdateRegisteredInvalidationIds(
54 syncer::InvalidationHandler* handler,
55 const syncer::ObjectIdSet& ids) {
56 invalidator_->UpdateRegisteredIds(handler, ids);
59 void P2PInvalidationService::UnregisterInvalidationHandler(
60 syncer::InvalidationHandler* handler) {
61 invalidator_->UnregisterHandler(handler);
64 void P2PInvalidationService::SendInvalidation(
65 const syncer::ObjectIdSet& ids) {
66 invalidator_->SendInvalidation(ids);
69 syncer::InvalidatorState P2PInvalidationService::GetInvalidatorState() const {
70 return invalidator_->GetInvalidatorState();
73 std::string P2PInvalidationService::GetInvalidatorClientId() const {
74 return invalidator_id_;
77 InvalidationLogger* P2PInvalidationService::GetInvalidationLogger() {
78 return NULL;
81 void P2PInvalidationService::RequestDetailedStatus(
82 base::Callback<void(const base::DictionaryValue&)> caller) const {
83 base::DictionaryValue value;
84 caller.Run(value);
87 IdentityProvider* P2PInvalidationService::GetIdentityProvider() {
88 return identity_provider_.get();
91 } // namespace invalidation