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

Side by Side Diff: net/base/network_delegate.h

Issue 10736066: Adding histograms showing fraction of page load times (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 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 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 NET_BASE_NETWORK_DELEGATE_H_ 5 #ifndef NET_BASE_NETWORK_DELEGATE_H_
6 #define NET_BASE_NETWORK_DELEGATE_H_ 6 #define NET_BASE_NETWORK_DELEGATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // OnAuthRequired call. It's placed in this file to prevent url_request.h 42 // OnAuthRequired call. It's placed in this file to prevent url_request.h
43 // from having to include network_delegate.h. 43 // from having to include network_delegate.h.
44 enum AuthRequiredResponse { 44 enum AuthRequiredResponse {
45 AUTH_REQUIRED_RESPONSE_NO_ACTION, 45 AUTH_REQUIRED_RESPONSE_NO_ACTION,
46 AUTH_REQUIRED_RESPONSE_SET_AUTH, 46 AUTH_REQUIRED_RESPONSE_SET_AUTH,
47 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, 47 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH,
48 AUTH_REQUIRED_RESPONSE_IO_PENDING, 48 AUTH_REQUIRED_RESPONSE_IO_PENDING,
49 }; 49 };
50 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; 50 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback;
51 51
52 enum CacheWaitState {
53 CACHE_WAIT_STATE_START,
54 CACHE_WAIT_STATE_FINISH,
55 CACHE_WAIT_STATE_DONE
56 };
57
52 virtual ~NetworkDelegate() {} 58 virtual ~NetworkDelegate() {}
53 59
54 // Notification interface called by the network stack. Note that these 60 // Notification interface called by the network stack. Note that these
55 // functions mostly forward to the private virtuals. They also add some sanity 61 // functions mostly forward to the private virtuals. They also add some sanity
56 // checking on parameters. See the corresponding virtuals for explanations of 62 // checking on parameters. See the corresponding virtuals for explanations of
57 // the methods and their arguments. 63 // the methods and their arguments.
58 int NotifyBeforeURLRequest(URLRequest* request, 64 int NotifyBeforeURLRequest(URLRequest* request,
59 const CompletionCallback& callback, 65 const CompletionCallback& callback,
60 GURL* new_url); 66 GURL* new_url);
61 int NotifyBeforeSendHeaders(URLRequest* request, 67 int NotifyBeforeSendHeaders(URLRequest* request,
(...skipping 22 matching lines...) Expand all
84 bool CanSetCookie(const URLRequest& request, 90 bool CanSetCookie(const URLRequest& request,
85 const std::string& cookie_line, 91 const std::string& cookie_line,
86 CookieOptions* options); 92 CookieOptions* options);
87 bool CanAccessFile(const URLRequest& request, 93 bool CanAccessFile(const URLRequest& request,
88 const FilePath& path) const; 94 const FilePath& path) const;
89 bool CanThrottleRequest(const URLRequest& request) const; 95 bool CanThrottleRequest(const URLRequest& request) const;
90 96
91 int NotifyBeforeSocketStreamConnect(SocketStream* socket, 97 int NotifyBeforeSocketStreamConnect(SocketStream* socket,
92 const CompletionCallback& callback); 98 const CompletionCallback& callback);
93 99
100 void NotifyCacheWaitStateChange(const URLRequest& request,
101 CacheWaitState state);
102
94 private: 103 private:
95 // This is the interface for subclasses of NetworkDelegate to implement. These 104 // This is the interface for subclasses of NetworkDelegate to implement. These
96 // member functions will be called by the respective public notification 105 // member functions will be called by the respective public notification
97 // member function, which will perform basic sanity checking. 106 // member function, which will perform basic sanity checking.
98 107
99 // Called before a request is sent. Allows the delegate to rewrite the URL 108 // Called before a request is sent. Allows the delegate to rewrite the URL
100 // being fetched by modifying |new_url|. |callback| and |new_url| are valid 109 // being fetched by modifying |new_url|. |callback| and |new_url| are valid
101 // only until OnURLRequestDestroyed is called for this request. Returns a net 110 // only until OnURLRequestDestroyed is called for this request. Returns a net
102 // status code, generally either OK to continue with the request or 111 // status code, generally either OK to continue with the request or
103 // ERR_IO_PENDING if the result is not ready yet. A status code other than OK 112 // ERR_IO_PENDING if the result is not ready yet. A status code other than OK
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 const FilePath& path) const = 0; 217 const FilePath& path) const = 0;
209 218
210 // Returns true if the given request may be rejected when the 219 // Returns true if the given request may be rejected when the
211 // URLRequestThrottlerManager believes the server servicing the 220 // URLRequestThrottlerManager believes the server servicing the
212 // request is overloaded or down. 221 // request is overloaded or down.
213 virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0; 222 virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0;
214 223
215 // Called before a SocketStream tries to connect. 224 // Called before a SocketStream tries to connect.
216 virtual int OnBeforeSocketStreamConnect( 225 virtual int OnBeforeSocketStreamConnect(
217 SocketStream* socket, const CompletionCallback& callback) = 0; 226 SocketStream* socket, const CompletionCallback& callback) = 0;
227
228 // Called when the completion of a URLRequest is blocking on a cache
229 // transaction (CACHE_WAIT_STATE_START), or when a URLRequest is no longer
230 // blocked on a cache transaction (CACHE_WAIT_STATE_FINISH), or when a
231 // URLRequest is completely done (CACHE_WAIT_STATE_DONE), indicating
232 // cancellation of any pending cache waits for this request. Notice that
233 // START called several times for the same request. It is the responsibility
234 // of the delegate to keep track of the number of outstanding cache
235 // transactions.
236 virtual void OnCacheWaitStateChange(const URLRequest& request,
237 CacheWaitState state) = 0;
218 }; 238 };
219 239
220 } // namespace net 240 } // namespace net
221 241
222 #endif // NET_BASE_NETWORK_DELEGATE_H_ 242 #endif // NET_BASE_NETWORK_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698