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

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

Issue 6966038: Anti-DDoS enhancements: Log to net log, UMA stats, improved policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 9 years, 6 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 #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/net/http_return.h" 9 #include "chrome/common/net/http_return.h"
10 #include "chrome/service/cloud_print/cloud_print_consts.h" 10 #include "chrome/service/cloud_print/cloud_print_consts.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 action = delegate_->HandleJSONData(source, 95 action = delegate_->HandleJSONData(source,
96 url, 96 url,
97 response_dict, 97 response_dict,
98 succeeded); 98 succeeded);
99 else 99 else
100 action = RETRY_REQUEST; 100 action = RETRY_REQUEST;
101 } 101 }
102 } 102 }
103 // Retry the request if needed. 103 // Retry the request if needed.
104 if (action == RETRY_REQUEST) { 104 if (action == RETRY_REQUEST) {
105 // If the response code is greater than or equal to 500, then the back-off 105 // Explicitly call ReceivedContentWasMalformed() to ensure the current
106 // period has been increased at the network level; otherwise, explicitly 106 // request gets counted as a failure for calculation of the back-off
107 // call ReceivedContentWasMalformed() to count the current request as a 107 // period. If it was already a failure by status code, this call will
108 // failure and increase the back-off period. 108 // be ignored.
109 if (response_code < 500) 109 request_->ReceivedContentWasMalformed();
110 request_->ReceivedContentWasMalformed();
111 110
112 ++num_retries_; 111 ++num_retries_;
113 if ((-1 != source->max_retries()) && 112 if ((-1 != source->max_retries()) &&
114 (num_retries_ > source->max_retries())) { 113 (num_retries_ > source->max_retries())) {
115 // Retry limit reached. Give up. 114 // Retry limit reached. Give up.
116 delegate_->OnRequestGiveUp(); 115 delegate_->OnRequestGiveUp();
117 } else { 116 } else {
118 // Either no retry limit specified or retry limit has not yet been 117 // Either no retry limit specified or retry limit has not yet been
119 // reached. Try again. Set up the request headers again because the token 118 // reached. Try again. Set up the request headers again because the token
120 // may have changed. 119 // may have changed.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 169
171 net::URLRequestContextGetter* CloudPrintURLFetcher::GetRequestContextGetter() { 170 net::URLRequestContextGetter* CloudPrintURLFetcher::GetRequestContextGetter() {
172 ServiceURLRequestContextGetter* getter = 171 ServiceURLRequestContextGetter* getter =
173 g_service_process->GetServiceURLRequestContextGetter(); 172 g_service_process->GetServiceURLRequestContextGetter();
174 // Now set up the user agent for cloudprint. 173 // Now set up the user agent for cloudprint.
175 std::string user_agent = getter->user_agent(); 174 std::string user_agent = getter->user_agent();
176 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); 175 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent);
177 getter->set_user_agent(user_agent); 176 getter->set_user_agent(user_agent);
178 return getter; 177 return getter;
179 } 178 }
OLDNEW
« no previous file with comments | « chrome/common/net/url_fetcher_unittest.cc ('k') | chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698