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: content/browser/ssl/ssl_error_handler.h

Issue 1459473003: Add a WebContents getter callback in ResourceRequestInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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 CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_
6 #define CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 6 #define CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/public/browser/global_request_id.h" 14 #include "content/public/browser/global_request_id.h"
15 #include "content/public/browser/resource_request_info.h"
15 #include "content/public/common/resource_type.h" 16 #include "content/public/common/resource_type.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace net { 19 namespace net {
19 class SSLInfo; 20 class SSLInfo;
20 class URLRequest; 21 class URLRequest;
21 } // namespace net 22 } // namespace net
22 23
23 namespace content { 24 namespace content {
24 25
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // warning message). 90 // warning message).
90 // This method can be called from OnDispatchFailed and OnDispatched. 91 // This method can be called from OnDispatchFailed and OnDispatched.
91 void DenyRequest(); 92 void DenyRequest();
92 93
93 // Does nothing on the net::URLRequest but ensures the current instance ref 94 // Does nothing on the net::URLRequest but ensures the current instance ref
94 // count is decremented appropriately. Subclasses that do not want to 95 // count is decremented appropriately. Subclasses that do not want to
95 // take any specific actions in their OnDispatched/OnDispatchFailed should 96 // take any specific actions in their OnDispatched/OnDispatchFailed should
96 // call this. 97 // call this.
97 void TakeNoAction(); 98 void TakeNoAction();
98 99
99 int render_process_id() const { return render_process_id_; } 100 const ResourceRequestInfo::WebContentsGetterOnUI& web_contents_getter()
100 int render_frame_id() const { return render_frame_id_; } 101 const {
102 return web_contents_getter_;
103 }
101 104
102 protected: 105 protected:
103 friend class base::RefCountedThreadSafe<SSLErrorHandler>; 106 friend class base::RefCountedThreadSafe<SSLErrorHandler>;
104 107
105 // Construct on the IO thread. 108 // Construct on the IO thread.
davidben 2015/11/19 17:46:13 Really we should make this class UI thread only. (
clamy 2015/11/20 13:50:42 Done.
106 SSLErrorHandler(const base::WeakPtr<Delegate>& delegate, 109 SSLErrorHandler(
107 ResourceType resource_type, 110 const base::WeakPtr<Delegate>& delegate,
108 const GURL& url, 111 ResourceType resource_type,
109 int render_process_id, 112 const GURL& url,
110 int render_frame_id); 113 const ResourceRequestInfo::WebContentsGetterOnUI& web_contents_getter);
111 114
112 virtual ~SSLErrorHandler(); 115 virtual ~SSLErrorHandler();
113 116
114 // The following 2 methods are the methods subclasses should implement. 117 // The following 2 methods are the methods subclasses should implement.
115 virtual void OnDispatchFailed(); 118 virtual void OnDispatchFailed();
116 119
117 // Can use the manager_ member. 120 // Can use the manager_ member.
118 virtual void OnDispatched(); 121 virtual void OnDispatched();
119 122
120 // Should only be accessed on the UI thread. 123 // Should only be accessed on the UI thread.
121 SSLManager* manager_; // Our manager. 124 SSLManager* manager_; // Our manager.
122 125
123 // The delegate we are associated with. 126 // The delegate we are associated with.
124 base::WeakPtr<Delegate> delegate_; 127 base::WeakPtr<Delegate> delegate_;
125 128
126 private: 129 private:
127 // Completes the CancelRequest operation on the IO thread. 130 // Completes the CancelRequest operation on the IO thread.
128 // Call on the IO thread. 131 // Call on the IO thread.
129 void CompleteCancelRequest(int error); 132 void CompleteCancelRequest(int error);
130 133
131 // Completes the ContinueRequest operation on the IO thread. 134 // Completes the ContinueRequest operation on the IO thread.
132 // 135 //
133 // Call on the IO thread. 136 // Call on the IO thread.
134 void CompleteContinueRequest(); 137 void CompleteContinueRequest();
135 138
136 // Derefs this instance. 139 // Derefs this instance.
137 // Call on the IO thread. 140 // Call on the IO thread.
138 void CompleteTakeNoAction(); 141 void CompleteTakeNoAction();
139 142
140 // We use these members to find the correct SSLManager when we arrive on 143 // We use this member to find the correct SSLManager when we arrive on the UI
141 // the UI thread. 144 // thread.
142 int render_process_id_; 145 ResourceRequestInfo::WebContentsGetterOnUI web_contents_getter_;
143 int render_frame_id_;
144 146
145 // The URL that we requested. 147 // The URL that we requested.
146 // This read-only member can be accessed on any thread. 148 // This read-only member can be accessed on any thread.
147 const GURL request_url_; 149 const GURL request_url_;
148 150
149 // What kind of resource is associated with the requested that generated 151 // What kind of resource is associated with the requested that generated
150 // that error. 152 // that error.
151 // This read-only member can be accessed on any thread. 153 // This read-only member can be accessed on any thread.
152 const ResourceType resource_type_; 154 const ResourceType resource_type_;
153 155
154 // A flag to make sure we notify the net::URLRequest exactly once. 156 // A flag to make sure we notify the net::URLRequest exactly once.
155 // Should only be accessed on the IO thread 157 // Should only be accessed on the IO thread
156 bool request_has_been_notified_; 158 bool request_has_been_notified_;
157 159
158 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); 160 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
159 }; 161 };
160 162
161 } // namespace content 163 } // namespace content
162 164
163 #endif // CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 165 #endif // CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698