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

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

Issue 8015004: webRequest.onAuthRequired listeners can provide authentication credentials. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle multiple blocking onAuthRequired Created 9 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 | 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 #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 "base/string16.h" 9 #include "base/string16.h"
10 #include "base/threading/non_thread_safe.h" 10 #include "base/threading/non_thread_safe.h"
11 #include "net/base/completion_callback.h" 11 #include "net/base/completion_callback.h"
12 12
13 class GURL; 13 class GURL;
14 14
15 namespace net { 15 namespace net {
16 16
17 // NOTE: Layering violations! 17 // NOTE: Layering violations!
18 // We decided to accept these violations (depending 18 // We decided to accept these violations (depending
19 // on other net/ submodules from net/base/), because otherwise NetworkDelegate 19 // on other net/ submodules from net/base/), because otherwise NetworkDelegate
20 // would have to be broken up into too many smaller interfaces targeted to each 20 // would have to be broken up into too many smaller interfaces targeted to each
21 // submodule. Also, since the lower levels in net/ may callback into higher 21 // submodule. Also, since the lower levels in net/ may callback into higher
22 // levels, we may encounter dangerous casting issues. 22 // levels, we may encounter dangerous casting issues.
23 // 23 //
24 // NOTE: It is not okay to add any compile-time dependencies on symbols outside 24 // NOTE: It is not okay to add any compile-time dependencies on symbols outside
25 // of net/base here, because we have a net_base library. Forward declarations 25 // of net/base here, because we have a net_base library. Forward declarations
26 // are ok. 26 // are ok.
27 class AuthChallengeInfo; 27 class AuthChallengeInfo;
28 class AuthCredentials;
28 class HostPortPair; 29 class HostPortPair;
29 class HttpRequestHeaders; 30 class HttpRequestHeaders;
30 class URLRequest; 31 class URLRequest;
31 class URLRequestJob; 32 class URLRequestJob;
32 33
33 class NetworkDelegate : public base::NonThreadSafe { 34 class NetworkDelegate : public base::NonThreadSafe {
34 public: 35 public:
35 virtual ~NetworkDelegate() {} 36 virtual ~NetworkDelegate() {}
36 37
37 // Notification interface called by the network stack. Note that these 38 // Notification interface called by the network stack. Note that these
38 // functions mostly forward to the private virtuals. They also add some sanity 39 // functions mostly forward to the private virtuals. They also add some sanity
39 // checking on parameters. See the corresponding virtuals for explanations of 40 // checking on parameters. See the corresponding virtuals for explanations of
40 // the methods and their arguments. 41 // the methods and their arguments.
41 int NotifyBeforeURLRequest(URLRequest* request, 42 int NotifyBeforeURLRequest(URLRequest* request,
42 CompletionCallback* callback, 43 CompletionCallback* callback,
43 GURL* new_url); 44 GURL* new_url);
44 int NotifyBeforeSendHeaders(URLRequest* request, 45 int NotifyBeforeSendHeaders(URLRequest* request,
45 CompletionCallback* callback, 46 CompletionCallback* callback,
46 HttpRequestHeaders* headers); 47 HttpRequestHeaders* headers);
47 void NotifySendHeaders(URLRequest* request, 48 void NotifySendHeaders(URLRequest* request,
48 const HttpRequestHeaders& headers); 49 const HttpRequestHeaders& headers);
49 void NotifyBeforeRedirect(URLRequest* request, 50 void NotifyBeforeRedirect(URLRequest* request,
50 const GURL& new_location); 51 const GURL& new_location);
51 void NotifyResponseStarted(URLRequest* request); 52 void NotifyResponseStarted(URLRequest* request);
52 void NotifyRawBytesRead(const URLRequest& request, int bytes_read); 53 void NotifyRawBytesRead(const URLRequest& request, int bytes_read);
53 void NotifyCompleted(URLRequest* request); 54 void NotifyCompleted(URLRequest* request);
54 void NotifyURLRequestDestroyed(URLRequest* request); 55 void NotifyURLRequestDestroyed(URLRequest* request);
55 void NotifyPACScriptError(int line_number, const string16& error); 56 void NotifyPACScriptError(int line_number, const string16& error);
56 void NotifyAuthRequired(URLRequest* request, 57 int NotifyAuthRequired(URLRequest* request,
57 const AuthChallengeInfo& auth_info); 58 const AuthChallengeInfo& auth_info,
59 CompletionCallback* callback,
60 AuthCredentials* credentials);
58 61
59 private: 62 private:
60 // This is the interface for subclasses of NetworkDelegate to implement. This 63 // This is the interface for subclasses of NetworkDelegate to implement. This
61 // member functions will be called by the respective public notification 64 // member functions will be called by the respective public notification
62 // member function, which will perform basic sanity checking. 65 // member function, which will perform basic sanity checking.
63 66
64 // Called before a request is sent. Allows the delegate to rewrite the URL 67 // Called before a request is sent. Allows the delegate to rewrite the URL
65 // being fetched by modifying |new_url|. |callback| and |new_url| are valid 68 // being fetched by modifying |new_url|. |callback| and |new_url| are valid
66 // only until OnURLRequestDestroyed is called for this request. Returns a net 69 // only until OnURLRequestDestroyed is called for this request. Returns a net
67 // status code, generally either OK to continue with the request or 70 // status code, generally either OK to continue with the request or
(...skipping 29 matching lines...) Expand all
97 100
98 // Called when an URLRequest is being destroyed. Note that the request is 101 // Called when an URLRequest is being destroyed. Note that the request is
99 // being deleted, so it's not safe to call any methods that may result in 102 // being deleted, so it's not safe to call any methods that may result in
100 // a virtual method call. 103 // a virtual method call.
101 virtual void OnURLRequestDestroyed(URLRequest* request) = 0; 104 virtual void OnURLRequestDestroyed(URLRequest* request) = 0;
102 105
103 // Corresponds to ProxyResolverJSBindings::OnError. 106 // Corresponds to ProxyResolverJSBindings::OnError.
104 virtual void OnPACScriptError(int line_number, const string16& error) = 0; 107 virtual void OnPACScriptError(int line_number, const string16& error) = 0;
105 108
106 // Corresponds to URLRequest::Delegate::OnAuthRequired. 109 // Corresponds to URLRequest::Delegate::OnAuthRequired.
107 virtual void OnAuthRequired(URLRequest* reqest, 110 virtual int OnAuthRequired(URLRequest* reqest,
108 const AuthChallengeInfo& auth_info) = 0; 111 const AuthChallengeInfo& auth_info,
112 CompletionCallback* callback,
113 AuthCredentials* credentials) = 0;
109 }; 114 };
110 115
111 } // namespace net 116 } // namespace net
112 117
113 #endif // NET_BASE_NETWORK_DELEGATE_H_ 118 #endif // NET_BASE_NETWORK_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698