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

Side by Side Diff: components/gcm_driver/gcm_desktop_utils.cc

Issue 1325063002: Componentizing chrome/browser/services/gcm/gcm_desktop_utils.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « components/gcm_driver/gcm_desktop_utils.h ('k') | no next file » | 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 "components/gcm_driver/gcm_desktop_utils.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/sequenced_task_runner.h" 8 #include "base/sequenced_task_runner.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "chrome/common/channel_info.h"
11 #include "components/gcm_driver/gcm_client_factory.h" 10 #include "components/gcm_driver/gcm_client_factory.h"
12 #include "components/gcm_driver/gcm_driver.h" 11 #include "components/gcm_driver/gcm_driver.h"
13 #include "components/gcm_driver/gcm_driver_desktop.h" 12 #include "components/gcm_driver/gcm_driver_desktop.h"
14 #include "components/sync_driver/sync_util.h" 13 #include "components/sync_driver/sync_util.h"
15 #include "components/version_info/version_info.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "url/gurl.h" 14 #include "url/gurl.h"
18 15
19 namespace gcm { 16 namespace gcm {
20 17
21 namespace { 18 namespace {
22 19
23 const char kChannelStatusRelativePath[] = "/experimentstatus"; 20 const char kChannelStatusRelativePath[] = "/experimentstatus";
24 21
25 GCMClient::ChromePlatform GetPlatform() { 22 GCMClient::ChromePlatform GetPlatform() {
26 #if defined(OS_WIN) 23 #if defined(OS_WIN)
27 return GCMClient::PLATFORM_WIN; 24 return GCMClient::PLATFORM_WIN;
28 #elif defined(OS_MACOSX) 25 #elif defined(OS_MACOSX)
29 return GCMClient::PLATFORM_MAC; 26 return GCMClient::PLATFORM_MAC;
30 #elif defined(OS_IOS) 27 #elif defined(OS_IOS)
31 return GCMClient::PLATFORM_IOS; 28 return GCMClient::PLATFORM_IOS;
32 #elif defined(OS_ANDROID) 29 #elif defined(OS_ANDROID)
33 return GCMClient::PLATFORM_ANDROID; 30 return GCMClient::PLATFORM_ANDROID;
34 #elif defined(OS_CHROMEOS) 31 #elif defined(OS_CHROMEOS)
35 return GCMClient::PLATFORM_CROS; 32 return GCMClient::PLATFORM_CROS;
36 #elif defined(OS_LINUX) 33 #elif defined(OS_LINUX)
37 return GCMClient::PLATFORM_LINUX; 34 return GCMClient::PLATFORM_LINUX;
38 #else 35 #else
39 // For all other platforms, return as LINUX. 36 // For all other platforms, return as LINUX.
40 return GCMClient::PLATFORM_LINUX; 37 return GCMClient::PLATFORM_LINUX;
41 #endif 38 #endif
42 } 39 }
43 40
44 GCMClient::ChromeChannel GetChannel() { 41 GCMClient::ChromeChannel GetChannel(version_info::Channel channel) {
45 version_info::Channel channel = chrome::GetChannel();
46 switch (channel) { 42 switch (channel) {
47 case version_info::Channel::UNKNOWN: 43 case version_info::Channel::UNKNOWN:
48 return GCMClient::CHANNEL_UNKNOWN; 44 return GCMClient::CHANNEL_UNKNOWN;
49 case version_info::Channel::CANARY: 45 case version_info::Channel::CANARY:
50 return GCMClient::CHANNEL_CANARY; 46 return GCMClient::CHANNEL_CANARY;
51 case version_info::Channel::DEV: 47 case version_info::Channel::DEV:
52 return GCMClient::CHANNEL_DEV; 48 return GCMClient::CHANNEL_DEV;
53 case version_info::Channel::BETA: 49 case version_info::Channel::BETA:
54 return GCMClient::CHANNEL_BETA; 50 return GCMClient::CHANNEL_BETA;
55 case version_info::Channel::STABLE: 51 case version_info::Channel::STABLE:
56 return GCMClient::CHANNEL_STABLE; 52 return GCMClient::CHANNEL_STABLE;
57 default: 53 default:
58 NOTREACHED(); 54 NOTREACHED();
59 return GCMClient::CHANNEL_UNKNOWN; 55 return GCMClient::CHANNEL_UNKNOWN;
60 } 56 }
61 } 57 }
62 58
63 std::string GetVersion() { 59 std::string GetVersion() {
64 return version_info::GetVersionNumber(); 60 return version_info::GetVersionNumber();
65 } 61 }
66 62
67 GCMClient::ChromeBuildInfo GetChromeBuildInfo() { 63 GCMClient::ChromeBuildInfo GetChromeBuildInfo(version_info::Channel channel) {
68 GCMClient::ChromeBuildInfo chrome_build_info; 64 GCMClient::ChromeBuildInfo chrome_build_info;
69 chrome_build_info.platform = GetPlatform(); 65 chrome_build_info.platform = GetPlatform();
70 chrome_build_info.channel = GetChannel(); 66 chrome_build_info.channel = GetChannel(channel);
71 chrome_build_info.version = GetVersion(); 67 chrome_build_info.version = GetVersion();
72 return chrome_build_info; 68 return chrome_build_info;
73 } 69 }
74 70
75 std::string GetChannelStatusRequestUrl() { 71 std::string GetChannelStatusRequestUrl(version_info::Channel channel) {
76 GURL sync_url(GetSyncServiceURL(*base::CommandLine::ForCurrentProcess(), 72 GURL sync_url(GetSyncServiceURL(*base::CommandLine::ForCurrentProcess(),
77 chrome::GetChannel())); 73 channel));
78 return sync_url.spec() + kChannelStatusRelativePath; 74 return sync_url.spec() + kChannelStatusRelativePath;
79 } 75 }
80 76
81 std::string GetUserAgent() { 77 std::string GetUserAgent(version_info::Channel channel) {
82 return MakeDesktopUserAgentForSync(chrome::GetChannel()); 78 return MakeDesktopUserAgentForSync(channel);
83 } 79 }
84 80
85 } // namespace 81 } // namespace
86 82
87 scoped_ptr<GCMDriver> CreateGCMDriverDesktop( 83 scoped_ptr<GCMDriver> CreateGCMDriverDesktop(
88 scoped_ptr<GCMClientFactory> gcm_client_factory, 84 scoped_ptr<GCMClientFactory> gcm_client_factory,
89 PrefService* prefs, 85 PrefService* prefs,
90 const base::FilePath& store_path, 86 const base::FilePath& store_path,
91 const scoped_refptr<net::URLRequestContextGetter>& request_context) { 87 const scoped_refptr<net::URLRequestContextGetter>& request_context,
92 88 version_info::Channel channel,
93 scoped_refptr<base::SequencedWorkerPool> worker_pool( 89 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner,
94 content::BrowserThread::GetBlockingPool()); 90 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
95 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( 91 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) {
droger 2015/09/02 08:39:32 The link error is because this code is not intende
96 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
97 worker_pool->GetSequenceToken(),
98 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
99 92
100 return scoped_ptr<GCMDriver>(new GCMDriverDesktop( 93 return scoped_ptr<GCMDriver>(new GCMDriverDesktop(
101 gcm_client_factory.Pass(), 94 gcm_client_factory.Pass(),
102 GetChromeBuildInfo(), 95 GetChromeBuildInfo(channel),
103 GetChannelStatusRequestUrl(), 96 GetChannelStatusRequestUrl(channel),
104 GetUserAgent(), 97 GetUserAgent(channel),
105 prefs, 98 prefs,
106 store_path, 99 store_path,
107 request_context, 100 request_context,
108 content::BrowserThread::GetMessageLoopProxyForThread( 101 ui_task_runner,
109 content::BrowserThread::UI), 102 io_task_runner,
110 content::BrowserThread::GetMessageLoopProxyForThread(
111 content::BrowserThread::IO),
112 blocking_task_runner)); 103 blocking_task_runner));
113 } 104 }
114 105
115 } // namespace gcm 106 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_desktop_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698