egl: Don't query EGL_POST_SUB_BUFFER_SUPPORTED_NV without extension
[chromium-blink-merge.git] / content / child / resource_loader_bridge.h
blob759f832737b657a9005cd87d79d94d501a01df37
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
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
7 // implemented by the embedder.
8 //
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
11 // no longer needed.
13 // In turn, the bridge's owner on the WebKit end will implement the
14 // RequestPeer interface, which we will use to communicate notifications
15 // back.
17 #ifndef CONTENT_CHILD_RESOURCE_LOADER_BRIDGE_H_
18 #define CONTENT_CHILD_RESOURCE_LOADER_BRIDGE_H_
20 #include "base/macros.h"
21 #include "content/common/content_export.h"
22 #include "net/base/request_priority.h"
24 namespace blink {
25 class WebThreadedDataReceiver;
28 namespace content {
30 class RequestPeer;
31 class ResourceRequestBody;
32 struct SyncLoadResponse;
34 // TODO(tfarina): Refactor code that uses this class. This shouldn't be needed
35 // now that it lives in content/.
36 class CONTENT_EXPORT ResourceLoaderBridge {
37 public:
38 // use BlinkPlatformImpl::CreateResourceLoader() for construction, but
39 // anybody can delete at any time, INCLUDING during processing of callbacks.
40 virtual ~ResourceLoaderBridge();
42 // Call this method before calling Start() to set the request body.
43 // May only be used with HTTP(S) POST requests.
44 virtual void SetRequestBody(ResourceRequestBody* request_body) = 0;
46 // Call this method to initiate the request. If this method succeeds, then
47 // the peer's methods will be called asynchronously to report various events.
48 virtual bool Start(RequestPeer* peer) = 0;
50 // Call this method to cancel a request that is in progress. This method
51 // causes the request to immediately transition into the 'done' state. The
52 // OnCompletedRequest method will be called asynchronously; this assumes
53 // the peer is still valid.
54 virtual void Cancel() = 0;
56 // Call this method to suspend or resume a load that is in progress. This
57 // method may only be called after a successful call to the Start method.
58 virtual void SetDefersLoading(bool value) = 0;
60 // Call this method when the priority of the requested resource changes after
61 // Start() has been called. This method may only be called after a successful
62 // call to the Start method.
63 virtual void DidChangePriority(net::RequestPriority new_priority,
64 int intra_priority_value) = 0;
66 // Call this method to attach a data receiver which will receive resource data
67 // on its own thread.
68 virtual bool AttachThreadedDataReceiver(
69 blink::WebThreadedDataReceiver* threaded_data_receiver) = 0;
71 // Call this method to load the resource synchronously (i.e., in one shot).
72 // This is an alternative to the Start method. Be warned that this method
73 // will block the calling thread until the resource is fully downloaded or an
74 // error occurs. It could block the calling thread for a long time, so only
75 // use this if you really need it! There is also no way for the caller to
76 // interrupt this method. Errors are reported via the status field of the
77 // response parameter.
78 virtual void SyncLoad(SyncLoadResponse* response) = 0;
80 protected:
81 // Construction must go through BlinkPlatformImpl::CreateResourceLoader().
82 // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload
83 // methods may be called to construct the body of the request.
84 ResourceLoaderBridge();
86 private:
87 DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge);
90 } // namespace content
92 #endif // CONTENT_CHILD_RESOURCE_LOADER_BRIDGE_H_