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

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

Issue 270873002: Extract GCMClient data types into separate gcm_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reupload Created 6 years, 7 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"
(...skipping 27 matching lines...) Expand all
38 38
39 void FakeGCMProfileService::RegisterFinished( 39 void FakeGCMProfileService::RegisterFinished(
40 const std::string& app_id, 40 const std::string& app_id,
41 const std::vector<std::string>& sender_ids, 41 const std::vector<std::string>& sender_ids,
42 RegisterCallback callback) { 42 RegisterCallback callback) {
43 if (collect_) { 43 if (collect_) {
44 last_registered_app_id_ = app_id; 44 last_registered_app_id_ = app_id;
45 last_registered_sender_ids_ = sender_ids; 45 last_registered_sender_ids_ = sender_ids;
46 } 46 }
47 47
48 callback.Run(base::UintToString(sender_ids.size()), GCMClient::SUCCESS); 48 callback.Run(base::UintToString(sender_ids.size()), RESULT_SUCCESS);
49 } 49 }
50 50
51 void FakeGCMProfileService::Unregister(const std::string& app_id, 51 void FakeGCMProfileService::Unregister(const std::string& app_id,
52 UnregisterCallback callback) { 52 UnregisterCallback callback) {
53 base::MessageLoop::current()->PostTask( 53 base::MessageLoop::current()->PostTask(
54 FROM_HERE, base::Bind(callback, GetNextExpectedUnregisterResponse())); 54 FROM_HERE, base::Bind(callback, GetNextExpectedUnregisterResponse()));
55 } 55 }
56 56
57 void FakeGCMProfileService::Send(const std::string& app_id, 57 void FakeGCMProfileService::Send(const std::string& app_id,
58 const std::string& receiver_id, 58 const std::string& receiver_id,
59 const GCMClient::OutgoingMessage& message, 59 const OutgoingMessage& message,
60 SendCallback callback) { 60 SendCallback callback) {
61 base::MessageLoop::current()->PostTask( 61 base::MessageLoop::current()->PostTask(
62 FROM_HERE, 62 FROM_HERE,
63 base::Bind(&FakeGCMProfileService::SendFinished, 63 base::Bind(&FakeGCMProfileService::SendFinished,
64 base::Unretained(this), 64 base::Unretained(this),
65 app_id, 65 app_id,
66 receiver_id, 66 receiver_id,
67 message, 67 message,
68 callback)); 68 callback));
69 } 69 }
70 70
71 void FakeGCMProfileService::SendFinished( 71 void FakeGCMProfileService::SendFinished(
72 const std::string& app_id, 72 const std::string& app_id,
73 const std::string& receiver_id, 73 const std::string& receiver_id,
74 const GCMClient::OutgoingMessage& message, 74 const OutgoingMessage& message,
75 SendCallback callback) { 75 SendCallback callback) {
76 if (collect_) { 76 if (collect_) {
77 last_sent_message_ = message; 77 last_sent_message_ = message;
78 last_receiver_id_ = receiver_id; 78 last_receiver_id_ = receiver_id;
79 } 79 }
80 80
81 callback.Run(message.id, GCMClient::SUCCESS); 81 callback.Run(message.id, RESULT_SUCCESS);
82 } 82 }
83 83
84 void FakeGCMProfileService::AddExpectedUnregisterResponse( 84 void FakeGCMProfileService::AddExpectedUnregisterResponse(
85 GCMClient::Result result) { 85 Result result) {
86 unregister_responses_.push_back(result); 86 unregister_responses_.push_back(result);
87 } 87 }
88 88
89 GCMClient::Result FakeGCMProfileService::GetNextExpectedUnregisterResponse() { 89 Result FakeGCMProfileService::GetNextExpectedUnregisterResponse() {
90 if (unregister_responses_.empty()) 90 if (unregister_responses_.empty())
91 return GCMClient::SUCCESS; 91 return RESULT_SUCCESS;
92 GCMClient::Result response = *unregister_responses_.begin(); 92 Result response = *unregister_responses_.begin();
93 unregister_responses_.erase(unregister_responses_.begin()); 93 unregister_responses_.erase(unregister_responses_.begin());
94 return response; 94 return response;
95 } 95 }
96 96
97 } // namespace gcm 97 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/fake_gcm_profile_service.h ('k') | chrome/browser/services/gcm/gcm_app_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698