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

Unified Diff: chrome/browser/gcm/fake_gcm_profile_service.h

Issue 2675293003: Push API: Don't wait for network when unsubscribing (Closed)
Patch Set: Address peter's review comments Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/gcm/fake_gcm_profile_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gcm/fake_gcm_profile_service.h
diff --git a/chrome/browser/gcm/fake_gcm_profile_service.h b/chrome/browser/gcm/fake_gcm_profile_service.h
index 7b4db7b858f0980e8677105a82af3be567708404..2a5ab46a17c23b6f29a236ca95c380a954292c71 100644
--- a/chrome/browser/gcm/fake_gcm_profile_service.h
+++ b/chrome/browser/gcm/fake_gcm_profile_service.h
@@ -10,7 +10,8 @@
#include <vector>
#include "base/macros.h"
-#include "components/gcm_driver/gcm_driver.h"
+#include "components/gcm_driver/common/gcm_messages.h"
+#include "components/gcm_driver/gcm_client.h"
#include "components/gcm_driver/gcm_profile_service.h"
class Profile;
@@ -24,8 +25,6 @@ namespace gcm {
// Acts as a bridge between GCM API and GCMClient layer for testing purposes.
class FakeGCMProfileService : public GCMProfileService {
public:
- typedef base::Callback<void(const std::string&)> UnregisterCallback;
-
// Helper function to be used with
// KeyedService::SetTestingFactory().
static std::unique_ptr<KeyedService> Build(content::BrowserContext* context);
@@ -33,17 +32,8 @@ class FakeGCMProfileService : public GCMProfileService {
explicit FakeGCMProfileService(Profile* profile);
~FakeGCMProfileService() override;
- void RegisterFinished(const std::string& app_id,
- const std::vector<std::string>& sender_ids);
- void UnregisterFinished(const std::string& app_id);
- void SendFinished(const std::string& app_id,
- const std::string& receiver_id,
- const OutgoingMessage& message);
-
void AddExpectedUnregisterResponse(GCMClient::Result result);
- void SetUnregisterCallback(const UnregisterCallback& callback);
-
void DispatchMessage(const std::string& app_id,
const IncomingMessage& message);
@@ -63,23 +53,26 @@ class FakeGCMProfileService : public GCMProfileService {
return last_registered_sender_ids_;
}
- void set_collect(bool collect) {
- collect_ = collect;
- }
+ // Set whether the service will collect parameters of the calls for further
+ // verification in tests.
+ void set_collect(bool collect) { collect_ = collect; }
+
+ // Crude offline simulation: requests fail and never run their callbacks (in
+ // reality, callbacks run within GetGCMBackoffPolicy().maximum_backoff_ms).
+ void set_offline(bool is_offline) { is_offline_ = is_offline; }
private:
- // Indicates whether the service will collect paramters of the calls for
- // furter verification in tests.
- bool collect_;
- // Used to give each registration a unique registration id. Does not decrease
- // when unregister is called.
- int registration_count_;
+ class CustomFakeGCMDriver;
+ friend class CustomFakeGCMDriver;
+
+ bool collect_ = false;
+ bool is_offline_ = false;
+
std::string last_registered_app_id_;
std::vector<std::string> last_registered_sender_ids_;
std::list<GCMClient::Result> unregister_responses_;
OutgoingMessage last_sent_message_;
std::string last_receiver_id_;
- UnregisterCallback unregister_callback_;
DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService);
};
« no previous file with comments | « no previous file | chrome/browser/gcm/fake_gcm_profile_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698