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

Side by Side Diff: chrome/service/cloud_print/cloud_print_url_fetcher.cc

Issue 12208089: Changing CloudPrintURLFetcher instantiation to be more testable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated Gene's suggestions Created 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/service/cloud_print/cloud_print_url_fetcher.h" 5 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/common/cloud_print/cloud_print_constants.h" 9 #include "chrome/common/cloud_print/cloud_print_constants.h"
10 #include "chrome/common/cloud_print/cloud_print_helpers.h" 10 #include "chrome/common/cloud_print/cloud_print_helpers.h"
11 #include "chrome/service/cloud_print/cloud_print_helpers.h" 11 #include "chrome/service/cloud_print/cloud_print_helpers.h"
12 #include "chrome/service/cloud_print/cloud_print_token_store.h" 12 #include "chrome/service/cloud_print/cloud_print_token_store.h"
13 #include "chrome/service/net/service_url_request_context.h" 13 #include "chrome/service/net/service_url_request_context.h"
14 #include "chrome/service/service_process.h" 14 #include "chrome/service/service_process.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
17 #include "net/http/http_status_code.h" 17 #include "net/http/http_status_code.h"
18 #include "net/url_request/url_fetcher.h" 18 #include "net/url_request/url_fetcher.h"
19 #include "net/url_request/url_request_status.h" 19 #include "net/url_request/url_request_status.h"
20 20
21 namespace cloud_print { 21 namespace cloud_print {
22 22
23 static CloudPrintURLFetcherFactory* g_factory = NULL;
24
25 // static
26 CloudPrintURLFetcher* CloudPrintURLFetcher::Create() {
27 CloudPrintURLFetcherFactory* factory = CloudPrintURLFetcher::factory();
28 return factory ? factory->CreateCloudPrintURLFetcher() :
29 new CloudPrintURLFetcher;
30 }
31
32 // static
33 CloudPrintURLFetcherFactory* CloudPrintURLFetcher::factory() {
34 return g_factory;
35 }
36
37 // static
38 void CloudPrintURLFetcher::set_factory(CloudPrintURLFetcherFactory* factory) {
39 g_factory = factory;
40 }
41
23 CloudPrintURLFetcher::ResponseAction 42 CloudPrintURLFetcher::ResponseAction
24 CloudPrintURLFetcher::Delegate::HandleRawResponse( 43 CloudPrintURLFetcher::Delegate::HandleRawResponse(
25 const net::URLFetcher* source, 44 const net::URLFetcher* source,
26 const GURL& url, 45 const GURL& url,
27 const net::URLRequestStatus& status, 46 const net::URLRequestStatus& status,
28 int response_code, 47 int response_code,
29 const net::ResponseCookies& cookies, 48 const net::ResponseCookies& cookies,
30 const std::string& data) { 49 const std::string& data) {
31 return CONTINUE_PROCESSING; 50 return CONTINUE_PROCESSING;
32 } 51 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 ServiceURLRequestContextGetter* getter = 227 ServiceURLRequestContextGetter* getter =
209 g_service_process->GetServiceURLRequestContextGetter(); 228 g_service_process->GetServiceURLRequestContextGetter();
210 // Now set up the user agent for cloudprint. 229 // Now set up the user agent for cloudprint.
211 std::string user_agent = getter->user_agent(); 230 std::string user_agent = getter->user_agent();
212 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); 231 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent);
213 getter->set_user_agent(user_agent); 232 getter->set_user_agent(user_agent);
214 return getter; 233 return getter;
215 } 234 }
216 235
217 } // namespace cloud_print 236 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_url_fetcher.h ('k') | chrome/service/cloud_print/cloud_print_wipeout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698