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

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

Powered by Google App Engine
This is Rietveld 408576698