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() { | |
22 } | |
23 | |
24 P2PInvalidationService::~P2PInvalidationService() { | |
25 } | |
26 | |
27 void P2PInvalidationService::Init(Profile* profile) { | |
28 notifier::NotifierOptions notifier_options = | |
29 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); | |
30 notifier_options.request_context_getter = profile->GetRequestContext(); | |
31 invalidator_id_ = GenerateInvalidatorClientId(); | |
tim (not reviewing)
2013/05/03 17:48:23
Wouldn't hurt to DCHECK or CHECK the id is non emp
rlarocque
2013/05/03 22:16:14
The comment for GenerateInvalidatorClientId() is c
tim (not reviewing)
2013/05/03 22:23:50
It seems sloppy to ignore the return value of Enco
rlarocque
2013/05/03 22:49:34
I added the DCHECK. I still don't understand how
| |
32 invalidator_.reset(new syncer::P2PInvalidator( | |
33 notifier::PushClient::CreateDefault(notifier_options), | |
34 invalidator_id_, | |
35 syncer::NOTIFY_ALL)); | |
36 } | |
37 | |
38 void P2PInvalidationService::UpdateCredentials(const std::string& username, | |
39 const std::string& password) { | |
40 invalidator_->UpdateCredentials(username, password); | |
41 } | |
42 | |
43 void P2PInvalidationService::Shutdown() { | |
44 invalidator_.reset(); | |
45 } | |
46 | |
47 void P2PInvalidationService::RegisterInvalidationHandler( | |
48 syncer::InvalidationHandler* handler) { | |
49 invalidator_->RegisterHandler(handler); | |
50 } | |
51 | |
52 void P2PInvalidationService::UpdateRegisteredInvalidationIds( | |
53 syncer::InvalidationHandler* handler, | |
54 const syncer::ObjectIdSet& ids) { | |
55 invalidator_->UpdateRegisteredIds(handler, ids); | |
56 } | |
57 | |
58 void P2PInvalidationService::UnregisterInvalidationHandler( | |
59 syncer::InvalidationHandler* handler) { | |
60 invalidator_->UnregisterHandler(handler); | |
61 } | |
62 | |
63 void P2PInvalidationService::AcknowledgeInvalidation( | |
64 const invalidation::ObjectId& id, | |
65 const syncer::AckHandle& ack_handle) { | |
66 invalidator_->Acknowledge(id, ack_handle); | |
67 } | |
68 | |
69 void P2PInvalidationService::SendInvalidation( | |
70 const syncer::ObjectIdInvalidationMap& invalidation_map) { | |
71 invalidator_->SendInvalidation(invalidation_map); | |
72 } | |
73 | |
74 syncer::InvalidatorState P2PInvalidationService::GetInvalidatorState() const { | |
75 return invalidator_->GetInvalidatorState(); | |
76 } | |
77 | |
78 std::string P2PInvalidationService::GetInvalidatorClientId() const { | |
79 return invalidator_id_; | |
80 } | |
81 | |
82 } // namespace invalidation | |
OLD | NEW |