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

Side by Side Diff: content/browser/ssl/ssl_error_handler.h

Issue 9406001: Factor out ResourceDispatcherHost dependent code around SSLManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase for retry Created 8 years, 9 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
« no previous file with comments | « content/browser/ssl/ssl_cert_error_handler.cc ('k') | content/browser/ssl/ssl_error_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "content/browser/ssl/ssl_manager.h"
14 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
15 #include "content/public/browser/global_request_id.h" 14 #include "content/public/browser/global_request_id.h"
16 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
17 #include "webkit/glue/resource_type.h" 16 #include "webkit/glue/resource_type.h"
18 17
19 class SSLCertErrorHandler; 18 class SSLCertErrorHandler;
19 class SSLManager;
20 20
21 namespace content { 21 namespace content {
22 class ResourceDispatcherHostImpl; 22 class ResourceDispatcherHostImpl;
23 } 23 }
24 24
25 namespace net { 25 namespace net {
26 class SSLInfo;
26 class URLRequest; 27 class URLRequest;
27 } // namespace net 28 } // namespace net
28 29
29 // An SSLErrorHandler carries information from the IO thread to the UI thread 30 // An SSLErrorHandler carries information from the IO thread to the UI thread
30 // and is dispatched to the appropriate SSLManager when it arrives on the 31 // and is dispatched to the appropriate SSLManager when it arrives on the
31 // UI thread. Subclasses should override the OnDispatched/OnDispatchFailed 32 // UI thread. Subclasses should override the OnDispatched/OnDispatchFailed
32 // methods to implement the actions that should be taken on the UI thread. 33 // methods to implement the actions that should be taken on the UI thread.
33 // These methods can call the different convenience methods ContinueRequest/ 34 // These methods can call the different convenience methods ContinueRequest/
34 // CancelRequest to perform any required action on the net::URLRequest the 35 // CancelRequest to perform any required action on the net::URLRequest the
35 // ErrorHandler was created with. 36 // ErrorHandler was created with.
36 // 37 //
37 // IMPORTANT NOTE: 38 // IMPORTANT NOTE:
38 // 39 //
39 // If you are not doing anything in OnDispatched/OnDispatchFailed, make sure 40 // If you are not doing anything in OnDispatched/OnDispatchFailed, make sure
40 // you call TakeNoAction(). This is necessary for ensuring the instance is 41 // you call TakeNoAction(). This is necessary for ensuring the instance is
41 // not leaked. 42 // not leaked.
42 // 43 //
43 class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> { 44 class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> {
44 public: 45 public:
46 // Delegate functions must be called from IO thread. All functions accept
47 // |id| as the first argument. |id| is a copy of the second argument of
48 // SSLManager::OnSSLCertificateError() and represents the request.
49 // Finally, CancelSSLRequest() or ContinueSSLRequest() will be called after
50 // SSLErrorHandler makes a decision on the SSL error.
51 class Delegate {
52 public:
53 // Called when SSLErrorHandler decides to cancel the request because of
54 // the SSL error.
55 virtual void CancelSSLRequest(const content::GlobalRequestID& id,
56 int error,
57 const net::SSLInfo* ssl_info) = 0;
58
59 // Called when SSLErrorHandler decides to continue the request despite the
60 // SSL error.
61 virtual void ContinueSSLRequest(const content::GlobalRequestID& id) = 0;
62 };
63
45 virtual SSLCertErrorHandler* AsSSLCertErrorHandler(); 64 virtual SSLCertErrorHandler* AsSSLCertErrorHandler();
46 65
47 // Find the appropriate SSLManager for the net::URLRequest and begin handling 66 // Find the appropriate SSLManager for the net::URLRequest and begin handling
48 // this error. 67 // this error.
49 // 68 //
50 // Call on UI thread. 69 // Call on UI thread.
51 void Dispatch(); 70 void Dispatch();
52 71
53 // Available on either thread. 72 // Available on either thread.
54 const GURL& request_url() const { return request_url_; } 73 const GURL& request_url() const { return request_url_; }
(...skipping 24 matching lines...) Expand all
79 // call this. 98 // call this.
80 void TakeNoAction(); 99 void TakeNoAction();
81 100
82 int render_process_id() const { return render_process_id_; } 101 int render_process_id() const { return render_process_id_; }
83 int render_view_id() const { return render_view_id_; } 102 int render_view_id() const { return render_view_id_; }
84 103
85 protected: 104 protected:
86 friend class base::RefCountedThreadSafe<SSLErrorHandler>; 105 friend class base::RefCountedThreadSafe<SSLErrorHandler>;
87 106
88 // Construct on the IO thread. 107 // Construct on the IO thread.
89 SSLErrorHandler(content::ResourceDispatcherHostImpl* host, 108 SSLErrorHandler(Delegate* delegate,
90 net::URLRequest* request, 109 const content::GlobalRequestID& id,
91 ResourceType::Type resource_type); 110 ResourceType::Type resource_type,
111 const GURL& url,
112 int render_process_id,
113 int render_view_id);
92 114
93 virtual ~SSLErrorHandler(); 115 virtual ~SSLErrorHandler();
94 116
95 // The following 2 methods are the methods subclasses should implement. 117 // The following 2 methods are the methods subclasses should implement.
96 virtual void OnDispatchFailed(); 118 virtual void OnDispatchFailed();
97 119
98 // Can use the manager_ member. 120 // Can use the manager_ member.
99 virtual void OnDispatched(); 121 virtual void OnDispatched();
100 122
101 // Should only be accessed on the UI thread. 123 // Should only be accessed on the UI thread.
102 SSLManager* manager_; // Our manager. 124 SSLManager* manager_; // Our manager.
103 125
104 // The id of the net::URLRequest associated with this object. 126 // The id of the request associated with this object.
105 // Should only be accessed from the IO thread. 127 // Should only be accessed from the IO thread.
106 content::GlobalRequestID request_id_; 128 content::GlobalRequestID request_id_;
107 129
108 // The ResourceDispatcherHostImpl we are associated with. 130 // The delegate we are associated with.
109 content::ResourceDispatcherHostImpl* resource_dispatcher_host_; 131 Delegate* delegate_;
110 132
111 private: 133 private:
112 // Completes the CancelRequest operation on the IO thread. 134 // Completes the CancelRequest operation on the IO thread.
113 // Call on the IO thread. 135 // Call on the IO thread.
114 void CompleteCancelRequest(int error); 136 void CompleteCancelRequest(int error);
115 137
116 // Completes the ContinueRequest operation on the IO thread. 138 // Completes the ContinueRequest operation on the IO thread.
117 // 139 //
118 // Call on the IO thread. 140 // Call on the IO thread.
119 void CompleteContinueRequest(); 141 void CompleteContinueRequest();
(...skipping 17 matching lines...) Expand all
137 const ResourceType::Type resource_type_; 159 const ResourceType::Type resource_type_;
138 160
139 // A flag to make sure we notify the net::URLRequest exactly once. 161 // A flag to make sure we notify the net::URLRequest exactly once.
140 // Should only be accessed on the IO thread 162 // Should only be accessed on the IO thread
141 bool request_has_been_notified_; 163 bool request_has_been_notified_;
142 164
143 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); 165 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
144 }; 166 };
145 167
146 #endif // CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 168 #endif // CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/ssl/ssl_cert_error_handler.cc ('k') | content/browser/ssl/ssl_error_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698