Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/browser/services/gcm/push_messaging_service_impl.cc

Issue 317823007: Hook PushMessagingMessageFilter up to GCMDriver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "chrome/browser/services/gcm/push_messaging_service_impl.h"
6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "chrome/browser/services/gcm/gcm_profile_service.h"
11 #include "components/gcm_driver/gcm_driver.h"
12
13 namespace gcm {
14
15 PushMessagingServiceImpl::PushMessagingServiceImpl(
16 GCMProfileService* gcm_profile_service)
17 : gcm_profile_service_(gcm_profile_service) {}
18
19 PushMessagingServiceImpl::~PushMessagingServiceImpl() {}
20
21 void PushMessagingServiceImpl::Register(
22 const std::string& app_id,
23 const std::string& sender_id,
24 const content::PushMessagingService::RegisterCallback& callback) {
25 if (!gcm_profile_service_->driver())
26 return;
27 std::vector<std::string> sender_ids(1, sender_id);
28 gcm_profile_service_->driver()->Register(
29 app_id,
30 sender_ids,
31 base::Bind(&PushMessagingServiceImpl::DidRegister,
32 base::Unretained(this),
33 callback));
34 }
35
36 void PushMessagingServiceImpl::DidRegister(
37 const content::PushMessagingService::RegisterCallback& callback,
38 const std::string& registration_id,
39 GCMClient::Result result) {
40 GURL endpoint = GURL("https://android.googleapis.com/gcm/send");
41 bool error = (result != GCMClient::SUCCESS);
42 callback.Run(endpoint, registration_id, error);
43 }
44
45 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698