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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gcm_desktop_utils.h" 5 #include "chrome/browser/services/gcm/gcm_desktop_utils.h"
6 6
7 #include "base/command_line.h"
7 #include "base/sequenced_task_runner.h" 8 #include "base/sequenced_task_runner.h"
8 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
9 #include "chrome/common/gcm_desktop_util.h" 10 #include "chrome/browser/services/gcm/gcm_desktop_utils.h"
11 #include "chrome/common/channel_info.h"
12 #include "chrome/common/sync_util.h"
10 #include "components/gcm_driver/gcm_client_factory.h" 13 #include "components/gcm_driver/gcm_client_factory.h"
11 #include "components/gcm_driver/gcm_driver.h" 14 #include "components/gcm_driver/gcm_driver.h"
15 #include "components/gcm_driver/gcm_driver_desktop.h"
16 #include "components/version_info/version_info.h"
12 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "url/gurl.h"
13 19
14 namespace gcm { 20 namespace gcm {
15 21
22 namespace {
23
24 const char kChannelStatusRelativePath[] = "/experimentstatus";
25
26 GCMClient::ChromePlatform GetPlatform() {
27 #if defined(OS_WIN)
28 return GCMClient::PLATFORM_WIN;
29 #elif defined(OS_MACOSX)
30 return GCMClient::PLATFORM_MAC;
31 #elif defined(OS_IOS)
32 return GCMClient::PLATFORM_IOS;
33 #elif defined(OS_ANDROID)
34 return GCMClient::PLATFORM_ANDROID;
35 #elif defined(OS_CHROMEOS)
36 return GCMClient::PLATFORM_CROS;
37 #elif defined(OS_LINUX)
38 return GCMClient::PLATFORM_LINUX;
39 #else
40 // For all other platforms, return as LINUX.
41 return GCMClient::PLATFORM_LINUX;
42 #endif
43 }
44
45 GCMClient::ChromeChannel GetChannel() {
46 version_info::Channel channel = chrome::GetChannel();
47 switch (channel) {
48 case version_info::Channel::UNKNOWN:
49 return GCMClient::CHANNEL_UNKNOWN;
50 case version_info::Channel::CANARY:
51 return GCMClient::CHANNEL_CANARY;
52 case version_info::Channel::DEV:
53 return GCMClient::CHANNEL_DEV;
54 case version_info::Channel::BETA:
55 return GCMClient::CHANNEL_BETA;
56 case version_info::Channel::STABLE:
57 return GCMClient::CHANNEL_STABLE;
58 default:
59 NOTREACHED();
60 return GCMClient::CHANNEL_UNKNOWN;
61 }
62 }
63
64 std::string GetVersion() {
65 return version_info::GetVersionNumber();
66 }
67
68 GCMClient::ChromeBuildInfo GetChromeBuildInfo() {
69 GCMClient::ChromeBuildInfo chrome_build_info;
70 chrome_build_info.platform = GetPlatform();
71 chrome_build_info.channel = GetChannel();
72 chrome_build_info.version = GetVersion();
73 return chrome_build_info;
74 }
75
76 std::string GetChannelStatusRequestUrl() {
77 GURL sync_url(GetSyncServiceURL(*base::CommandLine::ForCurrentProcess()));
78 return sync_url.spec() + kChannelStatusRelativePath;
79 }
80
81 std::string GetUserAgent() {
82 return MakeDesktopUserAgentForSync();
83 }
84
85 } // namespace
86
87 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
88 scoped_ptr<GCMClientFactory> gcm_client_factory,
89 PrefService* prefs,
90 const base::FilePath& store_path,
91 const scoped_refptr<net::URLRequestContextGetter>& request_context,
92 const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
93 const scoped_refptr<base::SequencedTaskRunner>& io_thread,
94 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) {
95 return scoped_ptr<GCMDriver>(new GCMDriverDesktop(
96 gcm_client_factory.Pass(), GetChromeBuildInfo(),
97 GetChannelStatusRequestUrl(), GetUserAgent(), prefs, store_path,
98 request_context, ui_thread, io_thread, blocking_task_runner));
99 }
100
16 scoped_ptr<GCMDriver> CreateGCMDriverDesktop( 101 scoped_ptr<GCMDriver> CreateGCMDriverDesktop(
17 scoped_ptr<GCMClientFactory> gcm_client_factory, 102 scoped_ptr<GCMClientFactory> gcm_client_factory,
18 PrefService* prefs, 103 PrefService* prefs,
19 const base::FilePath& store_path, 104 const base::FilePath& store_path,
20 const scoped_refptr<net::URLRequestContextGetter>& request_context) { 105 const scoped_refptr<net::URLRequestContextGetter>& request_context) {
21 106
22 scoped_refptr<base::SequencedWorkerPool> worker_pool( 107 scoped_refptr<base::SequencedWorkerPool> worker_pool(
23 content::BrowserThread::GetBlockingPool()); 108 content::BrowserThread::GetBlockingPool());
24 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( 109 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner(
25 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( 110 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
26 worker_pool->GetSequenceToken(), 111 worker_pool->GetSequenceToken(),
27 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); 112 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
28 113
29 return CreateGCMDriverDesktopWithTaskRunners( 114 return CreateGCMDriverDesktopWithTaskRunners(
30 gcm_client_factory.Pass(), 115 gcm_client_factory.Pass(),
31 prefs, 116 prefs,
32 store_path, 117 store_path,
33 request_context, 118 request_context,
34 content::BrowserThread::GetMessageLoopProxyForThread( 119 content::BrowserThread::GetMessageLoopProxyForThread(
35 content::BrowserThread::UI), 120 content::BrowserThread::UI),
36 content::BrowserThread::GetMessageLoopProxyForThread( 121 content::BrowserThread::GetMessageLoopProxyForThread(
37 content::BrowserThread::IO), 122 content::BrowserThread::IO),
38 blocking_task_runner); 123 blocking_task_runner);
39 } 124 }
40 125
41 } // namespace gcm 126 } // namespace gcm
OLDNEW
« 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