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

Side by Side Diff: chrome/browser/ui/search/new_tab_page_interceptor_service.cc

Issue 2264903003: Adjust callers and networking delegates in chrome/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: fix while loop Created 4 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
« no previous file with comments | « chrome/browser/prerender/prerender_resource_throttle_unittest.cc ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/search/new_tab_page_interceptor_service.h" 5 #include "chrome/browser/ui/search/new_tab_page_interceptor_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 net::URLRequestJob* MaybeInterceptResponse( 59 net::URLRequestJob* MaybeInterceptResponse(
60 net::URLRequest* request, 60 net::URLRequest* request,
61 net::NetworkDelegate* network_delegate) const override { 61 net::NetworkDelegate* network_delegate) const override {
62 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 62 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
63 if ((request->url() != new_tab_url_) || 63 if ((request->url() != new_tab_url_) ||
64 (new_tab_url_ == GURL(chrome::kChromeSearchLocalNtpUrl))) { 64 (new_tab_url_ == GURL(chrome::kChromeSearchLocalNtpUrl))) {
65 return nullptr; 65 return nullptr;
66 } 66 }
67 // User has canceled this navigation so it shouldn't be redirected. 67 // User has canceled this navigation so it shouldn't be redirected.
68 // TODO(maksims): Remove request->status() and use int net_error
69 // once MaybeInterceptResponse() starts to pass that.
68 if (request->status().status() == net::URLRequestStatus::CANCELED || 70 if (request->status().status() == net::URLRequestStatus::CANCELED ||
69 (request->status().status() == net::URLRequestStatus::FAILED && 71 (request->status().status() == net::URLRequestStatus::FAILED &&
70 request->status().error() == net::ERR_ABORTED)) { 72 request->status().error() == net::ERR_ABORTED)) {
71 return nullptr; 73 return nullptr;
72 } 74 }
73 75
74 // Request to NTP was successful. 76 // Request to NTP was successful.
77 // TODO(maksims): Remove request->status() and use int net_error
78 // once MaybeInterceptResponse() starts to pass that.
75 if (request->status().is_success() && 79 if (request->status().is_success() &&
76 request->GetResponseCode() != net::HTTP_NO_CONTENT && 80 request->GetResponseCode() != net::HTTP_NO_CONTENT &&
77 request->GetResponseCode() < 400) { 81 request->GetResponseCode() < 400) {
78 return nullptr; 82 return nullptr;
79 } 83 }
80 84
81 // Failure to load the NTP correctly; redirect to Local NTP. 85 // Failure to load the NTP correctly; redirect to Local NTP.
82 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad", 86 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad",
83 search::CACHEABLE_NTP_LOAD_FAILED, 87 search::CACHEABLE_NTP_LOAD_FAILED,
84 search::CACHEABLE_NTP_LOAD_MAX); 88 search::CACHEABLE_NTP_LOAD_MAX);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 121 }
118 122
119 std::unique_ptr<net::URLRequestInterceptor> 123 std::unique_ptr<net::URLRequestInterceptor>
120 NewTabPageInterceptorService::CreateInterceptor() { 124 NewTabPageInterceptorService::CreateInterceptor() {
121 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 125 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
122 std::unique_ptr<NewTabPageInterceptor> interceptor( 126 std::unique_ptr<NewTabPageInterceptor> interceptor(
123 new NewTabPageInterceptor(search::GetNewTabPageURL(profile_))); 127 new NewTabPageInterceptor(search::GetNewTabPageURL(profile_)));
124 interceptor_ = interceptor->GetWeakPtr(); 128 interceptor_ = interceptor->GetWeakPtr();
125 return std::move(interceptor); 129 return std::move(interceptor);
126 } 130 }
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_resource_throttle_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698