OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_STREAM_URL_H_ | |
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_STREAM_URL_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "url/gurl.h" | |
11 #include "webkit/plugins/npapi/plugin_stream.h" | |
12 #include "webkit/plugins/npapi/webplugin.h" | |
13 | |
14 namespace webkit { | |
15 namespace npapi { | |
16 | |
17 class PluginInstance; | |
18 | |
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); | |
32 | |
33 // Stop sending the stream to the client. | |
34 // Overrides the base Close so we can cancel our fetching the URL if | |
35 // it is still loading. | |
36 virtual bool Close(NPReason reason) OVERRIDE; | |
37 virtual WebPluginResourceClient* AsResourceClient() OVERRIDE; | |
38 virtual void CancelRequest() OVERRIDE; | |
39 | |
40 // WebPluginResourceClient methods | |
41 virtual void WillSendRequest(const GURL& url, int http_status_code) OVERRIDE; | |
42 virtual void DidReceiveResponse(const std::string& mime_type, | |
43 const std::string& headers, | |
44 uint32 expected_length, | |
45 uint32 last_modified, | |
46 bool request_is_seekable) OVERRIDE; | |
47 virtual void DidReceiveData(const char* buffer, | |
48 int length, | |
49 int data_offset) OVERRIDE; | |
50 virtual void DidFinishLoading(unsigned long resource_id) OVERRIDE; | |
51 virtual void DidFail(unsigned long resource_id) OVERRIDE; | |
52 virtual bool IsMultiByteResponseExpected() OVERRIDE; | |
53 virtual int ResourceId() OVERRIDE; | |
54 virtual void AddRangeRequestResourceId(unsigned long resource_id) OVERRIDE; | |
55 | |
56 protected: | |
57 virtual ~PluginStreamUrl(); | |
58 | |
59 private: | |
60 void SetDeferLoading(bool value); | |
61 | |
62 GURL url_; | |
63 unsigned long id_; | |
64 // Ids of additional resources requested via range requests issued on | |
65 // seekable streams. | |
66 std::vector<unsigned long> range_requests_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(PluginStreamUrl); | |
69 }; | |
70 | |
71 } // namespace npapi | |
72 } // namespace webkit | |
73 | |
74 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_STREAM_URL_H_ | |
OLD | NEW |