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
3 // found in the LICENSE file.
5 #ifndef CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_
6 #define CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "content/child/npapi/plugin_stream.h"
12 #include "content/child/npapi/webplugin_resource_client.h"
17 class PluginURLFetcher
;
19 // A NPAPI Stream based on a URL.
20 class PluginStreamUrl
: public PluginStream
,
21 public WebPluginResourceClient
{
23 // Create a new stream for sending to the plugin by fetching
24 // a URL. If notifyNeeded is set, then the plugin will be notified
25 // when the stream has been fully sent to the plugin. Initialize
26 // must be called before the object is used.
27 PluginStreamUrl(unsigned long resource_id
,
29 PluginInstance
*instance
,
33 void SetPluginURLFetcher(PluginURLFetcher
* fetcher
);
35 void URLRedirectResponse(bool allow
);
37 void FetchRange(const std::string
& range
);
39 // Stop sending the stream to the client.
40 // Overrides the base Close so we can cancel our fetching the URL if
41 // it is still loading.
42 bool Close(NPReason reason
) override
;
43 WebPluginResourceClient
* AsResourceClient() override
;
44 void CancelRequest() override
;
46 // WebPluginResourceClient methods
47 void WillSendRequest(const GURL
& url
, int http_status_code
) override
;
48 void DidReceiveResponse(const std::string
& mime_type
,
49 const std::string
& headers
,
50 uint32 expected_length
,
52 bool request_is_seekable
) override
;
53 void DidReceiveData(const char* buffer
, int length
, int data_offset
) override
;
54 void DidFinishLoading(unsigned long resource_id
) override
;
55 void DidFail(unsigned long resource_id
) override
;
56 bool IsMultiByteResponseExpected() override
;
57 int ResourceId() override
;
58 void AddRangeRequestResourceId(unsigned long resource_id
) override
;
61 ~PluginStreamUrl() override
;
64 void SetDeferLoading(bool value
);
66 // In case of a redirect, this can be called to update the url. But it must
67 // be called before Open().
68 void UpdateUrl(const char* url
);
73 // Ids of additional resources requested via range requests issued on
75 // This is used when we're loading resources through the renderer, i.e. not
76 // using plugin_url_fetcher_.
77 std::vector
<unsigned long> range_requests_
;
78 // This is used when we're using plugin_url_fetcher_.
79 std::vector
<PluginURLFetcher
*> range_request_fetchers_
;
81 // If the plugin participates in HTTP URL redirect handling then this member
82 // holds the url being redirected to while we wait for the plugin to make a
83 // decision on whether to allow or deny the redirect.
84 std::string pending_redirect_url_
;
86 scoped_ptr
<PluginURLFetcher
> plugin_url_fetcher_
;
88 DISALLOW_COPY_AND_ASSIGN(PluginStreamUrl
);
91 } // namespace content
93 #endif // CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_