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

Side by Side Diff: webkit/child/resource_loader_bridge.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
« no previous file with comments | « content/public/child/resource_dispatcher_delegate.h ('k') | no next file » | 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 // The intent of this file is to provide a type-neutral abstraction between 5 // The intent of this file is to provide a type-neutral abstraction between
6 // Chrome and WebKit for resource loading. This pure-virtual interface is 6 // Chrome and WebKit for resource loading. This pure-virtual interface is
7 // implemented by the embedder. 7 // implemented by the embedder.
8 // 8 //
9 // One of these objects will be created by WebKit for each request. WebKit 9 // One of these objects will be created by WebKit for each request. WebKit
10 // will own the pointer to the bridge, and will delete it when the request is 10 // will own the pointer to the bridge, and will delete it when the request is
11 // no longer needed. 11 // no longer needed.
12 // 12 //
13 // In turn, the bridge's owner on the WebKit end will implement the Peer 13 // In turn, the bridge's owner on the WebKit end will implement the
14 // interface, which we will use to communicate notifications back. 14 // RequestPeer interface, which we will use to communicate notifications
15 // back.
15 16
16 #ifndef WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_ 17 #ifndef WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_
17 #define WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_ 18 #define WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_
18 19
19 #include <utility> 20 #include "base/macros.h"
20
21 #include "build/build_config.h"
22 #if defined(OS_POSIX)
23 #include "base/file_descriptor_posix.h"
24 #endif
25 #include "base/memory/ref_counted.h"
26 #include "base/platform_file.h"
27 #include "base/values.h"
28 #include "net/base/request_priority.h" 21 #include "net/base/request_priority.h"
29 #include "url/gurl.h"
30 #include "webkit/child/webkit_child_export.h" 22 #include "webkit/child/webkit_child_export.h"
31 23
32 // TODO(pilgrim) remove this once resource loader is moved to content 24 // TODO(pilgrim) remove this once resource loader is moved to content
33 // http://crbug.com/338338 25 // http://crbug.com/338338
34 namespace content { 26 namespace content {
27 class RequestPeer;
35 class ResourceRequestBody; 28 class ResourceRequestBody;
36 struct SyncLoadResponse; 29 struct SyncLoadResponse;
37 } 30 }
38 31
39 namespace webkit_glue { 32 namespace webkit_glue {
40 33
41 struct ResourceResponseInfo;
42
43 class ResourceLoaderBridge { 34 class ResourceLoaderBridge {
44 public: 35 public:
45 // Generated by the bridge. This is implemented by our custom resource loader
46 // within webkit. The Peer and it's bridge should have identical lifetimes
47 // as they represent each end of a communication channel.
48 //
49 // These callbacks mirror net::URLRequest::Delegate and the order and
50 // conditions in which they will be called are identical. See url_request.h
51 // for more information.
52 class WEBKIT_CHILD_EXPORT Peer {
53 public:
54 // Called as upload progress is made.
55 // note: only for requests with LOAD_ENABLE_UPLOAD_PROGRESS set
56 virtual void OnUploadProgress(uint64 position, uint64 size) = 0;
57
58 // Called when a redirect occurs. The implementation may return false to
59 // suppress the redirect. The given ResponseInfo provides complete
60 // information about the redirect, and new_url is the URL that will be
61 // loaded if this method returns true. If this method returns true, the
62 // output parameter *has_new_first_party_for_cookies indicates whether the
63 // output parameter *new_first_party_for_cookies contains the new URL that
64 // should be consulted for the third-party cookie blocking policy.
65 virtual bool OnReceivedRedirect(const GURL& new_url,
66 const ResourceResponseInfo& info,
67 bool* has_new_first_party_for_cookies,
68 GURL* new_first_party_for_cookies) = 0;
69
70 // Called when response headers are available (after all redirects have
71 // been followed).
72 virtual void OnReceivedResponse(const ResourceResponseInfo& info) = 0;
73
74 // Called when a chunk of response data is downloaded. This method may be
75 // called multiple times or not at all if an error occurs. This method is
76 // only called if RequestInfo::download_to_file was set to true, and in
77 // that case, OnReceivedData will not be called.
78 // The encoded_data_length is the length of the encoded data transferred
79 // over the network, which could be different from data length (e.g. for
80 // gzipped content).
81 virtual void OnDownloadedData(int len, int encoded_data_length) = 0;
82
83 // Called when a chunk of response data is available. This method may
84 // be called multiple times or not at all if an error occurs.
85 // The encoded_data_length is the length of the encoded data transferred
86 // over the network, which could be different from data length (e.g. for
87 // gzipped content).
88 virtual void OnReceivedData(const char* data,
89 int data_length,
90 int encoded_data_length) = 0;
91
92 // Called when metadata generated by the renderer is retrieved from the
93 // cache. This method may be called zero or one times.
94 virtual void OnReceivedCachedMetadata(const char* data, int len) { }
95
96 // Called when the response is complete. This method signals completion of
97 // the resource load.
98 virtual void OnCompletedRequest(
99 int error_code,
100 bool was_ignored_by_handler,
101 bool stale_copy_in_cache,
102 const std::string& security_info,
103 const base::TimeTicks& completion_time,
104 int64 total_transfer_size) = 0;
105
106 protected:
107 virtual ~Peer() {}
108 };
109
110 // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but 36 // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but
111 // anybody can delete at any time, INCLUDING during processing of callbacks. 37 // anybody can delete at any time, INCLUDING during processing of callbacks.
112 WEBKIT_CHILD_EXPORT virtual ~ResourceLoaderBridge(); 38 WEBKIT_CHILD_EXPORT virtual ~ResourceLoaderBridge();
113 39
114 // Call this method before calling Start() to set the request body. 40 // Call this method before calling Start() to set the request body.
115 // May only be used with HTTP(S) POST requests. 41 // May only be used with HTTP(S) POST requests.
116 virtual void SetRequestBody(content::ResourceRequestBody* request_body) = 0; 42 virtual void SetRequestBody(content::ResourceRequestBody* request_body) = 0;
117 43
118 // Call this method to initiate the request. If this method succeeds, then 44 // Call this method to initiate the request. If this method succeeds, then
119 // the peer's methods will be called asynchronously to report various events. 45 // the peer's methods will be called asynchronously to report various events.
120 virtual bool Start(Peer* peer) = 0; 46 virtual bool Start(content::RequestPeer* peer) = 0;
121 47
122 // Call this method to cancel a request that is in progress. This method 48 // Call this method to cancel a request that is in progress. This method
123 // causes the request to immediately transition into the 'done' state. The 49 // causes the request to immediately transition into the 'done' state. The
124 // OnCompletedRequest method will be called asynchronously; this assumes 50 // OnCompletedRequest method will be called asynchronously; this assumes
125 // the peer is still valid. 51 // the peer is still valid.
126 virtual void Cancel() = 0; 52 virtual void Cancel() = 0;
127 53
128 // Call this method to suspend or resume a load that is in progress. This 54 // Call this method to suspend or resume a load that is in progress. This
129 // method may only be called after a successful call to the Start method. 55 // method may only be called after a successful call to the Start method.
130 virtual void SetDefersLoading(bool value) = 0; 56 virtual void SetDefersLoading(bool value) = 0;
(...skipping 19 matching lines...) Expand all
150 // methods may be called to construct the body of the request. 76 // methods may be called to construct the body of the request.
151 WEBKIT_CHILD_EXPORT ResourceLoaderBridge(); 77 WEBKIT_CHILD_EXPORT ResourceLoaderBridge();
152 78
153 private: 79 private:
154 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); 80 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge);
155 }; 81 };
156 82
157 } // namespace webkit_glue 83 } // namespace webkit_glue
158 84
159 #endif // WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_ 85 #endif // WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_
OLDNEW
« no previous file with comments | « content/public/child/resource_dispatcher_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698