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

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

Issue 183923006: [GCM] API update to allow only a single sender in registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 5 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 12
13 namespace gcm { 13 namespace gcm {
14 14
15 // static 15 // static
16 BrowserContextKeyedService* FakeGCMProfileService::Build( 16 BrowserContextKeyedService* FakeGCMProfileService::Build(
17 content::BrowserContext* context) { 17 content::BrowserContext* context) {
18 Profile* profile = static_cast<Profile*>(context); 18 Profile* profile = static_cast<Profile*>(context);
19 return new FakeGCMProfileService(profile); 19 return new FakeGCMProfileService(profile);
20 } 20 }
21 21
22 FakeGCMProfileService::FakeGCMProfileService(Profile* profile) 22 FakeGCMProfileService::FakeGCMProfileService(Profile* profile)
23 : GCMProfileService(profile), 23 : GCMProfileService(profile),
24 collect_(false) {} 24 collect_(false) {}
25 25
26 FakeGCMProfileService::~FakeGCMProfileService() {} 26 FakeGCMProfileService::~FakeGCMProfileService() {}
27 27
28 void FakeGCMProfileService::Register(const std::string& app_id, 28 void FakeGCMProfileService::Register(const std::string& app_id,
29 const std::vector<std::string>& sender_ids, 29 const std::string& sender_id,
30 const std::string& cert, 30 const std::string& cert,
31 RegisterCallback callback) { 31 RegisterCallback callback) {
32 base::MessageLoop::current()->PostTask( 32 base::MessageLoop::current()->PostTask(
33 FROM_HERE, 33 FROM_HERE,
34 base::Bind(&FakeGCMProfileService::RegisterFinished, 34 base::Bind(&FakeGCMProfileService::RegisterFinished,
35 base::Unretained(this), 35 base::Unretained(this),
36 app_id, 36 app_id,
37 sender_ids, 37 sender_id,
38 cert, 38 cert,
39 callback)); 39 callback));
40 } 40 }
41 41
42 void FakeGCMProfileService::RegisterFinished( 42 void FakeGCMProfileService::RegisterFinished(
43 const std::string& app_id, 43 const std::string& app_id,
44 const std::vector<std::string>& sender_ids, 44 const std::string& sender_id,
45 const std::string& cert, 45 const std::string& cert,
46 RegisterCallback callback) { 46 RegisterCallback callback) {
47 if (collect_) { 47 if (collect_) {
48 last_registered_app_id_ = app_id; 48 last_registered_app_id_ = app_id;
49 last_registered_sender_ids_ = sender_ids; 49 last_registered_sender_id_ = sender_id;
50 last_registered_cert_ = cert; 50 last_registered_cert_ = cert;
51 } 51 }
52 52
53 callback.Run(base::UintToString(sender_ids.size()), GCMClient::SUCCESS); 53 callback.Run(base::UintToString(sender_id.size()), GCMClient::SUCCESS);
54 } 54 }
55 55
56 void FakeGCMProfileService::Send(const std::string& app_id, 56 void FakeGCMProfileService::Send(const std::string& app_id,
57 const std::string& receiver_id, 57 const std::string& receiver_id,
58 const GCMClient::OutgoingMessage& message, 58 const GCMClient::OutgoingMessage& message,
59 SendCallback callback) { 59 SendCallback callback) {
60 base::MessageLoop::current()->PostTask( 60 base::MessageLoop::current()->PostTask(
61 FROM_HERE, 61 FROM_HERE,
62 base::Bind(&FakeGCMProfileService::SendFinished, 62 base::Bind(&FakeGCMProfileService::SendFinished,
63 base::Unretained(this), 63 base::Unretained(this),
(...skipping 10 matching lines...) Expand all
74 SendCallback callback) { 74 SendCallback callback) {
75 if (collect_) { 75 if (collect_) {
76 last_sent_message_ = message; 76 last_sent_message_ = message;
77 last_receiver_id_ = receiver_id; 77 last_receiver_id_ = receiver_id;
78 } 78 }
79 79
80 callback.Run(message.id, GCMClient::SUCCESS); 80 callback.Run(message.id, GCMClient::SUCCESS);
81 } 81 }
82 82
83 } // namespace gcm 83 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698