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

Side by Side Diff: chrome/renderer/security_filter_peer.h

Issue 218973002: Extract Peer interface out of ResourceLoaderBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: REBASED Created 6 years, 8 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 CHROME_RENDERER_SECURITY_FILTER_PEER_H_ 5 #ifndef CHROME_RENDERER_SECURITY_FILTER_PEER_H_
6 #define CHROME_RENDERER_SECURITY_FILTER_PEER_H_ 6 #define CHROME_RENDERER_SECURITY_FILTER_PEER_H_
7 7
8 #include "webkit/child/resource_loader_bridge.h" 8 #include "content/public/child/request_peer.h"
9 #include "webkit/common/resource_response_info.h" 9 #include "webkit/common/resource_response_info.h"
10 #include "webkit/common/resource_type.h" 10 #include "webkit/common/resource_type.h"
11 11
12 namespace webkit_glue {
13 class ResourceLoaderBridge;
14 }
15
12 // The SecurityFilterPeer is a proxy to a 16 // The SecurityFilterPeer is a proxy to a
13 // webkit_glue::ResourceLoaderBridge::Peer instance. It is used to pre-process 17 // content::RequestPeer instance. It is used to pre-process
14 // unsafe resources (such as mixed-content resource). 18 // unsafe resources (such as mixed-content resource).
15 // Call the factory method CreateSecurityFilterPeer() to obtain an instance of 19 // Call the factory method CreateSecurityFilterPeer() to obtain an instance of
16 // SecurityFilterPeer based on the original Peer. 20 // SecurityFilterPeer based on the original Peer.
17 // NOTE: subclasses should insure they delete themselves at the end of the 21 // NOTE: subclasses should insure they delete themselves at the end of the
18 // OnReceiveComplete call. 22 // OnReceiveComplete call.
19 class SecurityFilterPeer : public webkit_glue::ResourceLoaderBridge::Peer { 23 class SecurityFilterPeer : public content::RequestPeer {
20 public: 24 public:
21 virtual ~SecurityFilterPeer(); 25 virtual ~SecurityFilterPeer();
22 26
23 static SecurityFilterPeer* CreateSecurityFilterPeerForDeniedRequest( 27 static SecurityFilterPeer* CreateSecurityFilterPeerForDeniedRequest(
24 ResourceType::Type resource_type, 28 ResourceType::Type resource_type,
25 webkit_glue::ResourceLoaderBridge::Peer* peer, 29 content::RequestPeer* peer,
26 int os_error); 30 int os_error);
27 31
28 static SecurityFilterPeer* CreateSecurityFilterPeerForFrame( 32 static SecurityFilterPeer* CreateSecurityFilterPeerForFrame(
29 webkit_glue::ResourceLoaderBridge::Peer* peer, 33 content::RequestPeer* peer,
30 int os_error); 34 int os_error);
31 35
32 // ResourceLoaderBridge::Peer methods. 36 // content::RequestPeer methods.
33 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE; 37 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE;
34 virtual bool OnReceivedRedirect( 38 virtual bool OnReceivedRedirect(const GURL& new_url,
35 const GURL& new_url, 39 const webkit_glue::ResourceResponseInfo& info,
36 const webkit_glue::ResourceResponseInfo& info, 40 bool* has_new_first_party_for_cookies,
37 bool* has_new_first_party_for_cookies, 41 GURL* new_first_party_for_cookies) OVERRIDE;
38 GURL* new_first_party_for_cookies) OVERRIDE;
39 virtual void OnReceivedResponse( 42 virtual void OnReceivedResponse(
40 const webkit_glue::ResourceResponseInfo& info) OVERRIDE; 43 const webkit_glue::ResourceResponseInfo& info) OVERRIDE;
41 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE {} 44 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE {}
42 virtual void OnReceivedData(const char* data, 45 virtual void OnReceivedData(const char* data,
43 int data_length, 46 int data_length,
44 int encoded_data_length) OVERRIDE; 47 int encoded_data_length) OVERRIDE;
45 virtual void OnCompletedRequest( 48 virtual void OnCompletedRequest(int error_code,
46 int error_code, 49 bool was_ignored_by_handler,
47 bool was_ignored_by_handler, 50 bool stale_copy_in_cache,
48 bool stale_copy_in_cache, 51 const std::string& security_info,
49 const std::string& security_info, 52 const base::TimeTicks& completion_time,
50 const base::TimeTicks& completion_time, 53 int64 total_transfer_size) OVERRIDE;
51 int64 total_transfer_size) OVERRIDE;
52 54
53 protected: 55 protected:
54 SecurityFilterPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 56 SecurityFilterPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
55 webkit_glue::ResourceLoaderBridge::Peer* peer); 57 content::RequestPeer* peer);
56 58
57 webkit_glue::ResourceLoaderBridge::Peer* original_peer_; 59 content::RequestPeer* original_peer_;
58 webkit_glue::ResourceLoaderBridge* resource_loader_bridge_; 60 webkit_glue::ResourceLoaderBridge* resource_loader_bridge_;
59 61
60 private: 62 private:
61 DISALLOW_COPY_AND_ASSIGN(SecurityFilterPeer); 63 DISALLOW_COPY_AND_ASSIGN(SecurityFilterPeer);
62 }; 64 };
63 65
64 // The BufferedPeer reads all the data of the request into an internal buffer. 66 // The BufferedPeer reads all the data of the request into an internal buffer.
65 // Subclasses should implement DataReady() to process the data as necessary. 67 // Subclasses should implement DataReady() to process the data as necessary.
66 class BufferedPeer : public SecurityFilterPeer { 68 class BufferedPeer : public SecurityFilterPeer {
67 public: 69 public:
68 BufferedPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 70 BufferedPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
69 webkit_glue::ResourceLoaderBridge::Peer* peer, 71 content::RequestPeer* peer,
70 const std::string& mime_type); 72 const std::string& mime_type);
71 virtual ~BufferedPeer(); 73 virtual ~BufferedPeer();
72 74
73 // ResourceLoaderBridge::Peer Implementation. 75 // content::RequestPeer Implementation.
74 virtual void OnReceivedResponse( 76 virtual void OnReceivedResponse(
75 const webkit_glue::ResourceResponseInfo& info) OVERRIDE; 77 const webkit_glue::ResourceResponseInfo& info) OVERRIDE;
76 virtual void OnReceivedData(const char* data, 78 virtual void OnReceivedData(const char* data,
77 int data_length, 79 int data_length,
78 int encoded_data_length) OVERRIDE; 80 int encoded_data_length) OVERRIDE;
79 virtual void OnCompletedRequest( 81 virtual void OnCompletedRequest(
80 int error_code, 82 int error_code,
81 bool was_ignored_by_handler, 83 bool was_ignored_by_handler,
82 bool stale_copy_in_cache, 84 bool stale_copy_in_cache,
83 const std::string& security_info, 85 const std::string& security_info,
(...skipping 20 matching lines...) Expand all
104 // content instead. 106 // content instead.
105 // TODO(jcampan): we do not as of now cancel the request, as we do not have 107 // TODO(jcampan): we do not as of now cancel the request, as we do not have
106 // access to the resource_loader_bridge in the SecurityFilterPeer factory 108 // access to the resource_loader_bridge in the SecurityFilterPeer factory
107 // method. For now the resource is still being fetched, but ignored, as once 109 // method. For now the resource is still being fetched, but ignored, as once
108 // we have provided the replacement content, the associated pending request 110 // we have provided the replacement content, the associated pending request
109 // in ResourceDispatcher is removed and further OnReceived* notifications are 111 // in ResourceDispatcher is removed and further OnReceived* notifications are
110 // ignored. 112 // ignored.
111 class ReplaceContentPeer : public SecurityFilterPeer { 113 class ReplaceContentPeer : public SecurityFilterPeer {
112 public: 114 public:
113 ReplaceContentPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 115 ReplaceContentPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
114 webkit_glue::ResourceLoaderBridge::Peer* peer, 116 content::RequestPeer* peer,
115 const std::string& mime_type, 117 const std::string& mime_type,
116 const std::string& data); 118 const std::string& data);
117 virtual ~ReplaceContentPeer(); 119 virtual ~ReplaceContentPeer();
118 120
119 // ResourceLoaderBridge::Peer Implementation. 121 // content::RequestPeer Implementation.
120 virtual void OnReceivedResponse( 122 virtual void OnReceivedResponse(
121 const webkit_glue::ResourceResponseInfo& info) OVERRIDE; 123 const webkit_glue::ResourceResponseInfo& info) OVERRIDE;
122 virtual void OnReceivedData(const char* data, 124 virtual void OnReceivedData(const char* data,
123 int data_length, 125 int data_length,
124 int encoded_data_length) OVERRIDE; 126 int encoded_data_length) OVERRIDE;
125 virtual void OnCompletedRequest( 127 virtual void OnCompletedRequest(
126 int error_code, 128 int error_code,
127 bool was_ignored_by_handler, 129 bool was_ignored_by_handler,
128 bool stale_copy_in_cache, 130 bool stale_copy_in_cache,
129 const std::string& security_info, 131 const std::string& security_info,
130 const base::TimeTicks& completion_time, 132 const base::TimeTicks& completion_time,
131 int64 total_transfer_size) OVERRIDE; 133 int64 total_transfer_size) OVERRIDE;
132 134
133 private: 135 private:
134 webkit_glue::ResourceResponseInfo response_info_; 136 webkit_glue::ResourceResponseInfo response_info_;
135 std::string mime_type_; 137 std::string mime_type_;
136 std::string data_; 138 std::string data_;
137 139
138 DISALLOW_COPY_AND_ASSIGN(ReplaceContentPeer); 140 DISALLOW_COPY_AND_ASSIGN(ReplaceContentPeer);
139 }; 141 };
140 142
141 #endif // CHROME_RENDERER_SECURITY_FILTER_PEER_H_ 143 #endif // CHROME_RENDERER_SECURITY_FILTER_PEER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_localization_peer_unittest.cc ('k') | chrome/renderer/security_filter_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698