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"
12 #include "content/public/common/referrer.h"
16 class MultipartResponseDelegate
;
17 class PluginStreamUrl
;
18 class ResourceLoaderBridge
;
20 // Fetches URLS for a plugin using ResourceDispatcher.
21 class PluginURLFetcher
: public RequestPeer
{
23 PluginURLFetcher(PluginStreamUrl
* plugin_stream
,
25 const GURL
& first_party_for_cookies
,
26 const std::string
& method
,
29 const Referrer
& referrer
,
30 const std::string
& range
,
31 bool notify_redirects
,
32 bool is_plugin_src_load
,
36 unsigned long resource_id
,
37 bool copy_stream_data
);
38 ~PluginURLFetcher() override
;
40 // Cancels the current request.
43 // Called with the plugin's reply to NPP_URLRedirectNotify.
44 void URLRedirectResponse(bool allow
);
46 GURL
first_party_for_cookies() { return first_party_for_cookies_
; }
47 Referrer
referrer() { return referrer_
; }
48 int origin_pid() { return origin_pid_
; }
49 int render_frame_id() { return render_frame_id_
; }
50 int render_view_id() { return render_view_id_
; }
51 bool copy_stream_data() { return copy_stream_data_
; }
52 bool pending_failure_notification() { return pending_failure_notification_
; }
55 // RequestPeer implementation:
56 void OnUploadProgress(uint64 position
, uint64 size
) override
;
57 bool OnReceivedRedirect(const net::RedirectInfo
& redirect_info
,
58 const ResourceResponseInfo
& info
) override
;
59 void OnReceivedResponse(const ResourceResponseInfo
& info
) override
;
60 void OnDownloadedData(int len
, int encoded_data_length
) override
;
61 void OnReceivedData(const char* data
,
63 int encoded_data_length
) override
;
64 void OnCompletedRequest(int error_code
,
65 bool was_ignored_by_handler
,
66 bool stale_copy_in_cache
,
67 const std::string
& security_info
,
68 const base::TimeTicks
& completion_time
,
69 int64 total_transfer_size
) override
;
71 // |plugin_stream_| becomes NULL after Cancel() to ensure no further calls
73 PluginStreamUrl
* plugin_stream_
;
75 GURL first_party_for_cookies_
;
77 bool notify_redirects_
;
78 bool is_plugin_src_load_
;
82 unsigned long resource_id_
;
83 bool copy_stream_data_
;
85 bool pending_failure_notification_
;
87 scoped_ptr
<MultipartResponseDelegate
> multipart_delegate_
;
89 scoped_ptr
<ResourceLoaderBridge
> bridge_
;
91 DISALLOW_COPY_AND_ASSIGN(PluginURLFetcher
);
94 } // namespace content
96 #endif // CONTENT_CHILD_NPAPI_URL_FETCHER_H_