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

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, 2 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 | 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 17 matching lines...) Expand all
28 // must also be retried. 28 // must also be retried.
29 class CloudPrintURLFetcher 29 class CloudPrintURLFetcher
30 : public base::RefCountedThreadSafe<CloudPrintURLFetcher>, 30 : public base::RefCountedThreadSafe<CloudPrintURLFetcher>,
31 public URLFetcher::Delegate { 31 public URLFetcher::Delegate {
32 public: 32 public:
33 enum ResponseAction { 33 enum ResponseAction {
34 CONTINUE_PROCESSING, 34 CONTINUE_PROCESSING,
35 STOP_PROCESSING, 35 STOP_PROCESSING,
36 RETRY_REQUEST, 36 RETRY_REQUEST,
37 }; 37 };
38
38 class Delegate { 39 class Delegate {
39 public: 40 public:
40 virtual ~Delegate() { } 41 virtual ~Delegate() { }
41 // Override this to handle the raw response as it is available. No response 42 // Override this to handle the raw response as it is available. No response
42 // error checking is done before this method is called. If the delegate 43 // error checking is done before this method is called. If the delegate
43 // returns CONTINUE_PROCESSING, we will then check for network 44 // returns CONTINUE_PROCESSING, we will then check for network
44 // errors. Most implementations will not override this. 45 // errors. Most implementations will not override this.
45 virtual ResponseAction HandleRawResponse( 46 virtual ResponseAction HandleRawResponse(
46 const URLFetcher* source, 47 const URLFetcher* source,
47 const GURL& url, 48 const GURL& url,
(...skipping 22 matching lines...) Expand all
70 const GURL& url, 71 const GURL& url,
71 base::DictionaryValue* json_data, 72 base::DictionaryValue* json_data,
72 bool succeeded) { 73 bool succeeded) {
73 return CONTINUE_PROCESSING; 74 return CONTINUE_PROCESSING;
74 } 75 }
75 // Invoked when the retry limit for this request has been reached (if there 76 // Invoked when the retry limit for this request has been reached (if there
76 // was a retry limit - a limit of -1 implies no limit). 77 // was a retry limit - a limit of -1 implies no limit).
77 virtual void OnRequestGiveUp() { } 78 virtual void OnRequestGiveUp() { }
78 // Invoked when the request returns a 403 error (applicable only when 79 // Invoked when the request returns a 403 error (applicable only when
79 // HandleRawResponse returns CONTINUE_PROCESSING). 80 // HandleRawResponse returns CONTINUE_PROCESSING).
80 virtual void OnRequestAuthError() = 0; 81 // Returning RETRY_REQUEST will retry current request. (auth information
82 // may have been updated and new info is available through the
83 // Authenticator interface).
84 // Returning CONTINUE_PROCESSING will treat auth error as a netwrok error.
85 virtual ResponseAction OnRequestAuthError() = 0;
86
87 // Authentication information may change between retries.
88 // CloudPrintURLFetcher will request auth info before sending any request.
89 virtual std::string GetAuthHeader() = 0;
81 }; 90 };
82 CloudPrintURLFetcher(); 91 CloudPrintURLFetcher();
83 92
93 bool IsSameRequest(const URLFetcher* source);
94
84 void StartGetRequest(const GURL& url, 95 void StartGetRequest(const GURL& url,
85 Delegate* delegate, 96 Delegate* delegate,
86 int max_retries, 97 int max_retries,
87 const std::string& additional_headers); 98 const std::string& additional_headers);
88 void StartPostRequest(const GURL& url, 99 void StartPostRequest(const GURL& url,
89 Delegate* delegate, 100 Delegate* delegate,
90 int max_retries, 101 int max_retries,
91 const std::string& post_data_mime_type, 102 const std::string& post_data_mime_type,
92 const std::string& post_data, 103 const std::string& post_data,
93 const std::string& additional_headers); 104 const std::string& additional_headers);
(...skipping 26 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