Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / child / npapi / plugin_stream_url.h
blobf63593dd1423fbe3f056e0c195e2154554b9db9e
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_
8 #include <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "content/child/npapi/plugin_stream.h"
12 #include "content/child/npapi/webplugin_resource_client.h"
13 #include "url/gurl.h"
15 namespace content {
16 class PluginInstance;
17 class PluginURLFetcher;
19 // A NPAPI Stream based on a URL.
20 class PluginStreamUrl : public PluginStream,
21 public WebPluginResourceClient {
22 public:
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,
28 const GURL &url,
29 PluginInstance *instance,
30 bool notify_needed,
31 void *notify_data);
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 virtual bool Close(NPReason reason) OVERRIDE;
43 virtual WebPluginResourceClient* AsResourceClient() OVERRIDE;
44 virtual void CancelRequest() OVERRIDE;
46 // WebPluginResourceClient methods
47 virtual void WillSendRequest(const GURL& url, int http_status_code) OVERRIDE;
48 virtual void DidReceiveResponse(const std::string& mime_type,
49 const std::string& headers,
50 uint32 expected_length,
51 uint32 last_modified,
52 bool request_is_seekable) OVERRIDE;
53 virtual void DidReceiveData(const char* buffer,
54 int length,
55 int data_offset) OVERRIDE;
56 virtual void DidFinishLoading(unsigned long resource_id) OVERRIDE;
57 virtual void DidFail(unsigned long resource_id) OVERRIDE;
58 virtual bool IsMultiByteResponseExpected() OVERRIDE;
59 virtual int ResourceId() OVERRIDE;
60 virtual void AddRangeRequestResourceId(unsigned long resource_id) OVERRIDE;
62 protected:
63 virtual ~PluginStreamUrl();
65 private:
66 void SetDeferLoading(bool value);
68 // In case of a redirect, this can be called to update the url. But it must
69 // be called before Open().
70 void UpdateUrl(const char* url);
72 GURL url_;
73 unsigned long id_;
75 // Ids of additional resources requested via range requests issued on
76 // seekable streams.
77 // This is used when we're loading resources through the renderer, i.e. not
78 // using plugin_url_fetcher_.
79 std::vector<unsigned long> range_requests_;
80 // This is used when we're using plugin_url_fetcher_.
81 std::vector<PluginURLFetcher*> range_request_fetchers_;
83 // If the plugin participates in HTTP URL redirect handling then this member
84 // holds the url being redirected to while we wait for the plugin to make a
85 // decision on whether to allow or deny the redirect.
86 std::string pending_redirect_url_;
88 scoped_ptr<PluginURLFetcher> plugin_url_fetcher_;
90 DISALLOW_COPY_AND_ASSIGN(PluginStreamUrl);
93 } // namespace content
95 #endif // CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_