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

Unified Diff: chrome/browser/services/gcm/gcm_desktop_utils.cc

Issue 1297503003: Merging chrome/common/gcm_desktop_util.* and chrome/browser/services/gcm/gcm_desktop_util.*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/services/gcm/gcm_desktop_utils.h ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/services/gcm/gcm_desktop_utils.cc
diff --git a/chrome/browser/services/gcm/gcm_desktop_utils.cc b/chrome/browser/services/gcm/gcm_desktop_utils.cc
index cd7fb73d5466a54a5e7f55f846ffb6fbe649e979..004d924a4d5e4b7fe4333776138a37d5d1ce0fb5 100644
--- a/chrome/browser/services/gcm/gcm_desktop_utils.cc
+++ b/chrome/browser/services/gcm/gcm_desktop_utils.cc
@@ -4,15 +4,100 @@
#include "chrome/browser/services/gcm/gcm_desktop_utils.h"
+#include "base/command_line.h"
#include "base/sequenced_task_runner.h"
#include "base/threading/sequenced_worker_pool.h"
-#include "chrome/common/gcm_desktop_util.h"
+#include "chrome/browser/services/gcm/gcm_desktop_utils.h"
+#include "chrome/common/channel_info.h"
+#include "chrome/common/sync_util.h"
#include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_driver.h"
+#include "components/gcm_driver/gcm_driver_desktop.h"
+#include "components/version_info/version_info.h"
#include "content/public/browser/browser_thread.h"
+#include "url/gurl.h"
namespace gcm {
+namespace {
+
+const char kChannelStatusRelativePath[] = "/experimentstatus";
+
+GCMClient::ChromePlatform GetPlatform() {
+#if defined(OS_WIN)
+ return GCMClient::PLATFORM_WIN;
+#elif defined(OS_MACOSX)
+ return GCMClient::PLATFORM_MAC;
+#elif defined(OS_IOS)
+ return GCMClient::PLATFORM_IOS;
+#elif defined(OS_ANDROID)
+ return GCMClient::PLATFORM_ANDROID;
+#elif defined(OS_CHROMEOS)
+ return GCMClient::PLATFORM_CROS;
+#elif defined(OS_LINUX)
+ return GCMClient::PLATFORM_LINUX;
+#else
+ // For all other platforms, return as LINUX.
+ return GCMClient::PLATFORM_LINUX;
+#endif
+}
+
+GCMClient::ChromeChannel GetChannel() {
+ version_info::Channel channel = chrome::GetChannel();
+ switch (channel) {
+ case version_info::Channel::UNKNOWN:
+ return GCMClient::CHANNEL_UNKNOWN;
+ case version_info::Channel::CANARY:
+ return GCMClient::CHANNEL_CANARY;
+ case version_info::Channel::DEV:
+ return GCMClient::CHANNEL_DEV;
+ case version_info::Channel::BETA:
+ return GCMClient::CHANNEL_BETA;
+ case version_info::Channel::STABLE:
+ return GCMClient::CHANNEL_STABLE;
+ default:
+ NOTREACHED();
+ return GCMClient::CHANNEL_UNKNOWN;
+ }
+}
+
+std::string GetVersion() {
+ return version_info::GetVersionNumber();
+}
+
+GCMClient::ChromeBuildInfo GetChromeBuildInfo() {
+ GCMClient::ChromeBuildInfo chrome_build_info;
+ chrome_build_info.platform = GetPlatform();
+ chrome_build_info.channel = GetChannel();
+ chrome_build_info.version = GetVersion();
+ return chrome_build_info;
+}
+
+std::string GetChannelStatusRequestUrl() {
+ GURL sync_url(GetSyncServiceURL(*base::CommandLine::ForCurrentProcess()));
+ return sync_url.spec() + kChannelStatusRelativePath;
+}
+
+std::string GetUserAgent() {
+ return MakeDesktopUserAgentForSync();
+}
+
+} // namespace
+
+scoped_ptr<GCMDriver> CreateGCMDriverDesktopWithTaskRunners(
droger 2015/08/19 09:52:38 Maybe this could be moved to the anonymous namespa
Jitu( very slow this week) 2015/08/19 10:24:17 Actually we have declared this in header as part o
+ scoped_ptr<GCMClientFactory> gcm_client_factory,
+ PrefService* prefs,
+ const base::FilePath& store_path,
+ const scoped_refptr<net::URLRequestContextGetter>& request_context,
+ const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
+ const scoped_refptr<base::SequencedTaskRunner>& io_thread,
+ const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) {
+ return scoped_ptr<GCMDriver>(new GCMDriverDesktop(
+ gcm_client_factory.Pass(), GetChromeBuildInfo(),
+ GetChannelStatusRequestUrl(), GetUserAgent(), prefs, store_path,
+ request_context, ui_thread, io_thread, blocking_task_runner));
+}
+
scoped_ptr<GCMDriver> CreateGCMDriverDesktop(
scoped_ptr<GCMClientFactory> gcm_client_factory,
PrefService* prefs,
« no previous file with comments | « chrome/browser/services/gcm/gcm_desktop_utils.h ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698