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

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

Issue 8387011: Chrome proxy refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_
6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 20 matching lines...) Expand all
31 // must also be retried. 31 // must also be retried.
32 class CloudPrintURLFetcher 32 class CloudPrintURLFetcher
33 : public base::RefCountedThreadSafe<CloudPrintURLFetcher>, 33 : public base::RefCountedThreadSafe<CloudPrintURLFetcher>,
34 public content::URLFetcherDelegate { 34 public content::URLFetcherDelegate {
35 public: 35 public:
36 enum ResponseAction { 36 enum ResponseAction {
37 CONTINUE_PROCESSING, 37 CONTINUE_PROCESSING,
38 STOP_PROCESSING, 38 STOP_PROCESSING,
39 RETRY_REQUEST, 39 RETRY_REQUEST,
40 }; 40 };
41
41 class Delegate { 42 class Delegate {
42 public: 43 public:
43 virtual ~Delegate() { } 44 virtual ~Delegate() { }
44 // Override this to handle the raw response as it is available. No response 45 // Override this to handle the raw response as it is available. No response
45 // error checking is done before this method is called. If the delegate 46 // error checking is done before this method is called. If the delegate
46 // returns CONTINUE_PROCESSING, we will then check for network 47 // returns CONTINUE_PROCESSING, we will then check for network
47 // errors. Most implementations will not override this. 48 // errors. Most implementations will not override this.
48 virtual ResponseAction HandleRawResponse( 49 virtual ResponseAction HandleRawResponse(
49 const content::URLFetcher* source, 50 const content::URLFetcher* source,
50 const GURL& url, 51 const GURL& url,
(...skipping 22 matching lines...) Expand all
73 const GURL& url, 74 const GURL& url,
74 base::DictionaryValue* json_data, 75 base::DictionaryValue* json_data,
75 bool succeeded) { 76 bool succeeded) {
76 return CONTINUE_PROCESSING; 77 return CONTINUE_PROCESSING;
77 } 78 }
78 // Invoked when the retry limit for this request has been reached (if there 79 // Invoked when the retry limit for this request has been reached (if there
79 // was a retry limit - a limit of -1 implies no limit). 80 // was a retry limit - a limit of -1 implies no limit).
80 virtual void OnRequestGiveUp() { } 81 virtual void OnRequestGiveUp() { }
81 // Invoked when the request returns a 403 error (applicable only when 82 // Invoked when the request returns a 403 error (applicable only when
82 // HandleRawResponse returns CONTINUE_PROCESSING). 83 // HandleRawResponse returns CONTINUE_PROCESSING).
83 virtual void OnRequestAuthError() = 0; 84 // Returning RETRY_REQUEST will retry current request. (auth information
85 // may have been updated and new info is available through the
86 // Authenticator interface).
87 // Returning CONTINUE_PROCESSING will treat auth error as a netwrok error.
Scott Byer 2011/10/27 22:22:50 nit: spelling
88 virtual ResponseAction OnRequestAuthError() = 0;
89
90 // Authentication information may change between retries.
91 // CloudPrintURLFetcher will request auth info before sending any request.
92 virtual std::string GetAuthHeader() = 0;
84 }; 93 };
85 CloudPrintURLFetcher(); 94 CloudPrintURLFetcher();
86 95
96 bool IsSameRequest(const content::URLFetcher* source);
97
87 void StartGetRequest(const GURL& url, 98 void StartGetRequest(const GURL& url,
88 Delegate* delegate, 99 Delegate* delegate,
89 int max_retries, 100 int max_retries,
90 const std::string& additional_headers); 101 const std::string& additional_headers);
91 void StartPostRequest(const GURL& url, 102 void StartPostRequest(const GURL& url,
92 Delegate* delegate, 103 Delegate* delegate,
93 int max_retries, 104 int max_retries,
94 const std::string& post_data_mime_type, 105 const std::string& post_data_mime_type,
95 const std::string& post_data, 106 const std::string& post_data,
96 const std::string& additional_headers); 107 const std::string& additional_headers);
(...skipping 23 matching lines...) Expand all
120 int num_retries_; 131 int num_retries_;
121 URLFetcher::RequestType request_type_; 132 URLFetcher::RequestType request_type_;
122 std::string additional_headers_; 133 std::string additional_headers_;
123 std::string post_data_mime_type_; 134 std::string post_data_mime_type_;
124 std::string post_data_; 135 std::string post_data_;
125 }; 136 };
126 137
127 typedef CloudPrintURLFetcher::Delegate CloudPrintURLFetcherDelegate; 138 typedef CloudPrintURLFetcher::Delegate CloudPrintURLFetcherDelegate;
128 139
129 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ 140 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698