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

Unified Diff: chrome/browser/push_messaging/push_messaging_service_impl.cc

Issue 186023002: DO NOT REVIEW Plumb push messaging registration through to gcm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_service_impl.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/push_messaging/push_messaging_service_impl.cc
diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chrome/browser/push_messaging/push_messaging_service_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..145d92e04fbc27d0a6e42095d4dd60cbeaca4395
--- /dev/null
+++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/push_messaging/push_messaging_service_impl.h"
+
+#include "base/bind.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/services/gcm/gcm_profile_service.h"
+#include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
+
+PushMessagingServiceImpl::PushMessagingServiceImpl(Profile* profile)
+ : profile_(profile) {}
+
+PushMessagingServiceImpl::~PushMessagingServiceImpl() {}
+
+void PushMessagingServiceImpl::Register(
+ content::PushMessagingService::RegisterCallback callback) {
+ std::string app_id = "test_app_id";
+ std::vector<std::string> sender_ids;
+ sender_ids.push_back("test_sender_id");
+ gcm::GCMProfileServiceFactory::GetForProfile(profile_)->Register(
+ app_id,
+ sender_ids,
+ base::Bind(&PushMessagingServiceImpl::DidRegister, this, callback));
+}
+
+void PushMessagingServiceImpl::DidRegister(
+ content::PushMessagingService::RegisterCallback callback,
+ const std::string& registration_id,
+ gcm::GCMClient::Result result) {
+ callback.Run(registration_id, FromGCMClientResult(result));
+}
+
+content::PushMessagingStatus PushMessagingServiceImpl::FromGCMClientResult(
+ gcm::GCMClient::Result result) {
+ switch (result) {
+ case gcm::GCMClient::SUCCESS:
+ return content::PUSH_MESSAGING_STATUS_OK;
+ case gcm::GCMClient::INVALID_PARAMETER:
+ return content::PUSH_MESSAGING_STATUS_INVALID_PARAMETER;
+ case gcm::GCMClient::NOT_SIGNED_IN:
+ return content::PUSH_MESSAGING_STATUS_NOT_SIGNED_IN;
+ case gcm::GCMClient::ASYNC_OPERATION_PENDING:
+ return content::PUSH_MESSAGING_STATUS_OPERATION_PENDING;
+ case gcm::GCMClient::NETWORK_ERROR:
+ return content::PUSH_MESSAGING_STATUS_NETWORK_ERROR;
+ case gcm::GCMClient::SERVER_ERROR:
+ return content::PUSH_MESSAGING_STATUS_SERVER_ERROR;
+ case gcm::GCMClient::TTL_EXCEEDED:
+ return content::PUSH_MESSAGING_STATUS_TTL_EXCEEDED;
+ case gcm::GCMClient::UNKNOWN_ERROR:
+ return content::PUSH_MESSAGING_STATUS_UNKNOWN_ERROR;
+ };
+ NOTREACHED();
+ return content::PUSH_MESSAGING_STATUS_UNKNOWN_ERROR;
+}
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_service_impl.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698