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

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: reflects wtc's review Created 8 years, 10 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) 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 ResourceDispatcherHost;
20 class SSLCertErrorHandler; 18 class SSLCertErrorHandler;
19 class SSLManager;
21 20
22 namespace net { 21 namespace net {
22 class SSLInfo;
23 class URLRequest; 23 class URLRequest;
24 } // namespace net 24 } // namespace net
25 25
26 // An SSLErrorHandler carries information from the IO thread to the UI thread 26 // An SSLErrorHandler carries information from the IO thread to the UI thread
27 // and is dispatched to the appropriate SSLManager when it arrives on the 27 // and is dispatched to the appropriate SSLManager when it arrives on the
28 // UI thread. Subclasses should override the OnDispatched/OnDispatchFailed 28 // UI thread. Subclasses should override the OnDispatched/OnDispatchFailed
29 // methods to implement the actions that should be taken on the UI thread. 29 // methods to implement the actions that should be taken on the UI thread.
30 // These methods can call the different convenience methods ContinueRequest/ 30 // These methods can call the different convenience methods ContinueRequest/
31 // CancelRequest to perform any required action on the net::URLRequest the 31 // CancelRequest to perform any required action on the net::URLRequest the
32 // ErrorHandler was created with. 32 // ErrorHandler was created with.
33 // 33 //
34 // IMPORTANT NOTE: 34 // IMPORTANT NOTE:
35 // 35 //
36 // If you are not doing anything in OnDispatched/OnDispatchFailed, make sure 36 // If you are not doing anything in OnDispatched/OnDispatchFailed, make sure
37 // you call TakeNoAction(). This is necessary for ensuring the instance is 37 // you call TakeNoAction(). This is necessary for ensuring the instance is
38 // not leaked. 38 // not leaked.
39 // 39 //
40 class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> { 40 class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> {
41 public: 41 public:
42 // Delegate functions must be called from IO thread. All functions accept
43 // |id| as athe first argument. |id| is a copy of the second argument of
wtc 2012/02/24 00:44:38 Typo: athe => the
Takashi Toyoshima 2012/02/28 20:55:43 Done.
44 // SSLManager::OnSSLCertificateError() and represents the request.
45 // Query functions are used to retrieve the request related information.
46 // At last, CancelSSLRequest() or ContinueSSLRequest() will be called after
wtc 2012/02/24 00:44:38 Nit: "At last" probably should be "Finally" or "La
Takashi Toyoshima 2012/02/28 20:55:43 Done.
47 // SSLErrorHandler makes a decision on the SSL error.
48 class Delegate {
49 public:
50 // Query what kind of resource is associated with a request that generated
wtc 2012/02/24 00:44:38 Nit: change "Query" to "Queries" in these comments
Takashi Toyoshima 2012/02/28 20:55:43 Done.
51 // the error.
52 virtual ResourceType::Type ResourceTypeForSSLRequest(
wtc 2012/02/24 00:44:38 Nit: I suggest changing "SSLRequest" to just "Requ
Takashi Toyoshima 2012/02/28 20:55:43 As we discussed offline, the postfix "Request" wil
53 const content::GlobalRequestID& id) = 0;
54
55 // Query the requested URL which generated the error.
56 virtual const GURL& URLForSSLRequest(
57 const content::GlobalRequestID& id) = 0;
58
59 // Query the render process and view ids which represent RenderViewHost
60 // to which the request belong.
61 virtual bool RenderViewForSSLRequest(const content::GlobalRequestID& id,
62 int* render_process_host_id,
63 int* render_view_host_id) = 0;
64
65 // Called when SSLErrorHandler decides to cancel the request because of
66 // the SSL error.
67 virtual void CancelSSLRequest(const content::GlobalRequestID& id,
68 int error,
69 const net::SSLInfo* ssl_info) = 0;
70
71 // Called when SSLErrorHandler decides to continue the request despite the
72 // SSL error.
73 virtual void ContinueSSLRequest(const content::GlobalRequestID& id) = 0;
74 };
42 virtual SSLCertErrorHandler* AsSSLCertErrorHandler(); 75 virtual SSLCertErrorHandler* AsSSLCertErrorHandler();
43 76
44 // Find the appropriate SSLManager for the net::URLRequest and begin handling 77 // Find the appropriate SSLManager for the net::URLRequest and begin handling
45 // this error. 78 // this error.
46 // 79 //
47 // Call on UI thread. 80 // Call on UI thread.
48 void Dispatch(); 81 void Dispatch();
49 82
50 // Available on either thread. 83 // Available on either thread.
51 const GURL& request_url() const { return request_url_; } 84 const GURL& request_url() const { return request_url_; }
(...skipping 24 matching lines...) Expand all
76 // call this. 109 // call this.
77 void TakeNoAction(); 110 void TakeNoAction();
78 111
79 int render_process_id() const { return render_process_id_; } 112 int render_process_id() const { return render_process_id_; }
80 int render_view_id() const { return render_view_id_; } 113 int render_view_id() const { return render_view_id_; }
81 114
82 protected: 115 protected:
83 friend class base::RefCountedThreadSafe<SSLErrorHandler>; 116 friend class base::RefCountedThreadSafe<SSLErrorHandler>;
84 117
85 // Construct on the IO thread. 118 // Construct on the IO thread.
86 SSLErrorHandler(ResourceDispatcherHost* resource_dispatcher_host, 119 SSLErrorHandler(Delegate* delegate, const content::GlobalRequestID& id);
87 net::URLRequest* request,
88 ResourceType::Type resource_type);
89 120
90 virtual ~SSLErrorHandler(); 121 virtual ~SSLErrorHandler();
91 122
92 // The following 2 methods are the methods subclasses should implement. 123 // The following 2 methods are the methods subclasses should implement.
93 virtual void OnDispatchFailed(); 124 virtual void OnDispatchFailed();
94 125
95 // Can use the manager_ member. 126 // Can use the manager_ member.
96 virtual void OnDispatched(); 127 virtual void OnDispatched();
97 128
98 // Should only be accessed on the UI thread. 129 // Should only be accessed on the UI thread.
99 SSLManager* manager_; // Our manager. 130 SSLManager* manager_; // Our manager.
100 131
101 // The id of the net::URLRequest associated with this object. 132 // The id of the request associated with this object.
102 // Should only be accessed from the IO thread. 133 // Should only be accessed from the IO thread.
103 content::GlobalRequestID request_id_; 134 content::GlobalRequestID request_id_;
104 135
105 // The ResourceDispatcherHost we are associated with. 136 // The delegate we are associated with.
106 ResourceDispatcherHost* resource_dispatcher_host_; 137 Delegate* delegate_;
107 138
108 private: 139 private:
109 // Completes the CancelRequest operation on the IO thread. 140 // Completes the CancelRequest operation on the IO thread.
110 // Call on the IO thread. 141 // Call on the IO thread.
111 void CompleteCancelRequest(int error); 142 void CompleteCancelRequest(int error);
112 143
113 // Completes the ContinueRequest operation on the IO thread. 144 // Completes the ContinueRequest operation on the IO thread.
114 // 145 //
115 // Call on the IO thread. 146 // Call on the IO thread.
116 void CompleteContinueRequest(); 147 void CompleteContinueRequest();
(...skipping 17 matching lines...) Expand all
134 const ResourceType::Type resource_type_; 165 const ResourceType::Type resource_type_;
135 166
136 // A flag to make sure we notify the net::URLRequest exactly once. 167 // A flag to make sure we notify the net::URLRequest exactly once.
137 // Should only be accessed on the IO thread 168 // Should only be accessed on the IO thread
138 bool request_has_been_notified_; 169 bool request_has_been_notified_;
139 170
140 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); 171 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
141 }; 172 };
142 173
143 #endif // CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 174 #endif // CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698