Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / net / base / network_delegate.cc
blobd30a4ab4c88db1a56c850ebdcdb106cf30061805
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
3 // found in the LICENSE file.
5 #include "net/base/network_delegate.h"
7 #include "base/logging.h"
8 #include "net/base/load_flags.h"
9 #include "net/base/net_errors.h"
10 #include "net/url_request/url_request.h"
12 namespace net {
14 int NetworkDelegate::NotifyBeforeURLRequest(
15 URLRequest* request, const CompletionCallback& callback,
16 GURL* new_url) {
17 DCHECK(CalledOnValidThread());
18 DCHECK(request);
19 DCHECK(!callback.is_null());
20 return OnBeforeURLRequest(request, callback, new_url);
23 int NetworkDelegate::NotifyBeforeSendHeaders(
24 URLRequest* request, const CompletionCallback& callback,
25 HttpRequestHeaders* headers) {
26 DCHECK(CalledOnValidThread());
27 DCHECK(headers);
28 DCHECK(!callback.is_null());
29 return OnBeforeSendHeaders(request, callback, headers);
32 void NetworkDelegate::NotifySendHeaders(URLRequest* request,
33 const HttpRequestHeaders& headers) {
34 DCHECK(CalledOnValidThread());
35 OnSendHeaders(request, headers);
38 int NetworkDelegate::NotifyHeadersReceived(
39 URLRequest* request,
40 const CompletionCallback& callback,
41 const HttpResponseHeaders* original_response_headers,
42 scoped_refptr<HttpResponseHeaders>* override_response_headers,
43 GURL* allowed_unsafe_redirect_url) {
44 DCHECK(CalledOnValidThread());
45 DCHECK(original_response_headers);
46 DCHECK(!callback.is_null());
47 return OnHeadersReceived(request,
48 callback,
49 original_response_headers,
50 override_response_headers,
51 allowed_unsafe_redirect_url);
54 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) {
55 DCHECK(CalledOnValidThread());
56 DCHECK(request);
57 OnResponseStarted(request);
60 void NetworkDelegate::NotifyRawBytesRead(const URLRequest& request,
61 int bytes_read) {
62 DCHECK(CalledOnValidThread());
63 OnRawBytesRead(request, bytes_read);
66 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request,
67 const GURL& new_location) {
68 DCHECK(CalledOnValidThread());
69 DCHECK(request);
70 OnBeforeRedirect(request, new_location);
73 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) {
74 DCHECK(CalledOnValidThread());
75 DCHECK(request);
76 OnCompleted(request, started);
79 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) {
80 DCHECK(CalledOnValidThread());
81 DCHECK(request);
82 OnURLRequestDestroyed(request);
85 void NetworkDelegate::NotifyPACScriptError(int line_number,
86 const base::string16& error) {
87 DCHECK(CalledOnValidThread());
88 OnPACScriptError(line_number, error);
91 NetworkDelegate::AuthRequiredResponse NetworkDelegate::NotifyAuthRequired(
92 URLRequest* request,
93 const AuthChallengeInfo& auth_info,
94 const AuthCallback& callback,
95 AuthCredentials* credentials) {
96 DCHECK(CalledOnValidThread());
97 return OnAuthRequired(request, auth_info, callback, credentials);
100 int NetworkDelegate::NotifyBeforeSocketStreamConnect(
101 SocketStream* socket,
102 const CompletionCallback& callback) {
103 DCHECK(CalledOnValidThread());
104 DCHECK(socket);
105 DCHECK(!callback.is_null());
106 return OnBeforeSocketStreamConnect(socket, callback);
109 bool NetworkDelegate::CanGetCookies(const URLRequest& request,
110 const CookieList& cookie_list) {
111 DCHECK(CalledOnValidThread());
112 DCHECK(!(request.load_flags() & net::LOAD_DO_NOT_SEND_COOKIES));
113 return OnCanGetCookies(request, cookie_list);
116 bool NetworkDelegate::CanSetCookie(const URLRequest& request,
117 const std::string& cookie_line,
118 CookieOptions* options) {
119 DCHECK(CalledOnValidThread());
120 DCHECK(!(request.load_flags() & net::LOAD_DO_NOT_SAVE_COOKIES));
121 return OnCanSetCookie(request, cookie_line, options);
124 bool NetworkDelegate::CanAccessFile(const URLRequest& request,
125 const base::FilePath& path) const {
126 DCHECK(CalledOnValidThread());
127 return OnCanAccessFile(request, path);
130 bool NetworkDelegate::CanThrottleRequest(const URLRequest& request) const {
131 DCHECK(CalledOnValidThread());
132 return OnCanThrottleRequest(request);
135 bool NetworkDelegate::CanEnablePrivacyMode(
136 const GURL& url,
137 const GURL& first_party_for_cookies) const {
138 DCHECK(CalledOnValidThread());
139 return OnCanEnablePrivacyMode(url, first_party_for_cookies);
142 int NetworkDelegate::OnBeforeURLRequest(URLRequest* request,
143 const CompletionCallback& callback,
144 GURL* new_url) {
145 return OK;
148 int NetworkDelegate::OnBeforeSendHeaders(URLRequest* request,
149 const CompletionCallback& callback,
150 HttpRequestHeaders* headers) {
151 return OK;
154 void NetworkDelegate::OnSendHeaders(URLRequest* request,
155 const HttpRequestHeaders& headers) {
158 int NetworkDelegate::OnHeadersReceived(
159 URLRequest* request,
160 const CompletionCallback& callback,
161 const HttpResponseHeaders* original_response_headers,
162 scoped_refptr<HttpResponseHeaders>* override_response_headers,
163 GURL* allowed_unsafe_redirect_url) {
164 return OK;
167 void NetworkDelegate::OnBeforeRedirect(URLRequest* request,
168 const GURL& new_location) {
171 void NetworkDelegate::OnResponseStarted(URLRequest* request) {
174 void NetworkDelegate::OnRawBytesRead(const URLRequest& request,
175 int bytes_read) {
178 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) {
181 void NetworkDelegate::OnURLRequestDestroyed(URLRequest* request) {
184 void NetworkDelegate::OnPACScriptError(int line_number,
185 const base::string16& error) {
188 NetworkDelegate::AuthRequiredResponse NetworkDelegate::OnAuthRequired(
189 URLRequest* request,
190 const AuthChallengeInfo& auth_info,
191 const AuthCallback& callback,
192 AuthCredentials* credentials) {
193 return AUTH_REQUIRED_RESPONSE_NO_ACTION;
196 bool NetworkDelegate::OnCanGetCookies(const URLRequest& request,
197 const CookieList& cookie_list) {
198 return true;
201 bool NetworkDelegate::OnCanSetCookie(const URLRequest& request,
202 const std::string& cookie_line,
203 CookieOptions* options) {
204 return true;
207 bool NetworkDelegate::OnCanAccessFile(const URLRequest& request,
208 const base::FilePath& path) const {
209 return false;
212 bool NetworkDelegate::OnCanThrottleRequest(const URLRequest& request) const {
213 return false;
216 bool NetworkDelegate::OnCanEnablePrivacyMode(
217 const GURL& url,
218 const GURL& first_party_for_cookies) const {
219 return false;
222 int NetworkDelegate::OnBeforeSocketStreamConnect(
223 SocketStream* socket,
224 const CompletionCallback& callback) {
225 return OK;
228 } // namespace net