1 // Copyright (c) 2013 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.
5 #ifndef CONTENT_CHILD_NPAPI_URL_FETCHER_H_
6 #define CONTENT_CHILD_NPAPI_URL_FETCHER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/child/request_peer.h"
14 namespace webkit_glue
{
15 class ResourceLoaderBridge
;
19 class MultipartResponseDelegate
;
20 class PluginStreamUrl
;
22 // Fetches URLS for a plugin using ResourceDispatcher.
23 class PluginURLFetcher
: public RequestPeer
{
25 PluginURLFetcher(PluginStreamUrl
* plugin_stream
,
27 const GURL
& first_party_for_cookies
,
28 const std::string
& method
,
32 const std::string
& range
,
33 bool notify_redirects
,
34 bool is_plugin_src_load
,
38 unsigned long resource_id
,
39 bool copy_stream_data
);
40 virtual ~PluginURLFetcher();
42 // Cancels the current request.
45 // Called with the plugin's reply to NPP_URLRedirectNotify.
46 void URLRedirectResponse(bool allow
);
48 GURL
first_party_for_cookies() { return first_party_for_cookies_
; }
49 GURL
referrer() { return referrer_
; }
50 int origin_pid() { return origin_pid_
; }
51 int render_frame_id() { return render_frame_id_
; }
52 int render_view_id() { return render_view_id_
; }
53 bool copy_stream_data() { return copy_stream_data_
; }
54 bool pending_failure_notification() { return pending_failure_notification_
; }
57 // RequestPeer implementation:
58 virtual void OnUploadProgress(uint64 position
, uint64 size
) OVERRIDE
;
59 virtual bool OnReceivedRedirect(const net::RedirectInfo
& redirect_info
,
60 const ResourceResponseInfo
& info
) OVERRIDE
;
61 virtual void OnReceivedResponse(const ResourceResponseInfo
& info
) OVERRIDE
;
62 virtual void OnDownloadedData(int len
, int encoded_data_length
) OVERRIDE
;
63 virtual void OnReceivedData(const char* data
,
65 int encoded_data_length
) OVERRIDE
;
66 virtual void OnCompletedRequest(int error_code
,
67 bool was_ignored_by_handler
,
68 bool stale_copy_in_cache
,
69 const std::string
& security_info
,
70 const base::TimeTicks
& completion_time
,
71 int64 total_transfer_size
) OVERRIDE
;
73 // |plugin_stream_| becomes NULL after Cancel() to ensure no further calls
75 PluginStreamUrl
* plugin_stream_
;
77 GURL first_party_for_cookies_
;
79 bool notify_redirects_
;
80 bool is_plugin_src_load_
;
84 unsigned long resource_id_
;
85 bool copy_stream_data_
;
87 bool pending_failure_notification_
;
89 scoped_ptr
<MultipartResponseDelegate
> multipart_delegate_
;
91 scoped_ptr
<webkit_glue::ResourceLoaderBridge
> bridge_
;
93 DISALLOW_COPY_AND_ASSIGN(PluginURLFetcher
);
96 } // namespace content
98 #endif // CONTENT_CHILD_NPAPI_URL_FETCHER_H_