OLD | NEW |
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::vector<std::string>& sender_ids, |
30 const std::string& cert, | |
31 RegisterCallback callback) { | 30 RegisterCallback callback) { |
32 base::MessageLoop::current()->PostTask( | 31 base::MessageLoop::current()->PostTask( |
33 FROM_HERE, | 32 FROM_HERE, |
34 base::Bind(&FakeGCMProfileService::RegisterFinished, | 33 base::Bind(&FakeGCMProfileService::RegisterFinished, |
35 base::Unretained(this), | 34 base::Unretained(this), |
36 app_id, | 35 app_id, |
37 sender_ids, | 36 sender_ids, |
38 cert, | |
39 callback)); | 37 callback)); |
40 } | 38 } |
41 | 39 |
42 void FakeGCMProfileService::RegisterFinished( | 40 void FakeGCMProfileService::RegisterFinished( |
43 const std::string& app_id, | 41 const std::string& app_id, |
44 const std::vector<std::string>& sender_ids, | 42 const std::vector<std::string>& sender_ids, |
45 const std::string& cert, | |
46 RegisterCallback callback) { | 43 RegisterCallback callback) { |
47 if (collect_) { | 44 if (collect_) { |
48 last_registered_app_id_ = app_id; | 45 last_registered_app_id_ = app_id; |
49 last_registered_sender_ids_ = sender_ids; | 46 last_registered_sender_ids_ = sender_ids; |
50 last_registered_cert_ = cert; | |
51 } | 47 } |
52 | 48 |
53 callback.Run(base::UintToString(sender_ids.size()), GCMClient::SUCCESS); | 49 callback.Run(base::UintToString(sender_ids.size()), GCMClient::SUCCESS); |
54 } | 50 } |
55 | 51 |
56 void FakeGCMProfileService::Send(const std::string& app_id, | 52 void FakeGCMProfileService::Send(const std::string& app_id, |
57 const std::string& receiver_id, | 53 const std::string& receiver_id, |
58 const GCMClient::OutgoingMessage& message, | 54 const GCMClient::OutgoingMessage& message, |
59 SendCallback callback) { | 55 SendCallback callback) { |
60 base::MessageLoop::current()->PostTask( | 56 base::MessageLoop::current()->PostTask( |
(...skipping 13 matching lines...) Expand all Loading... |
74 SendCallback callback) { | 70 SendCallback callback) { |
75 if (collect_) { | 71 if (collect_) { |
76 last_sent_message_ = message; | 72 last_sent_message_ = message; |
77 last_receiver_id_ = receiver_id; | 73 last_receiver_id_ = receiver_id; |
78 } | 74 } |
79 | 75 |
80 callback.Run(message.id, GCMClient::SUCCESS); | 76 callback.Run(message.id, GCMClient::SUCCESS); |
81 } | 77 } |
82 | 78 |
83 } // namespace gcm | 79 } // namespace gcm |
OLD | NEW |