blob: 5b82de7d5edd04a33f7a955c17b0f252ed959193 [file] [log] [blame]
[email protected]f7817822009-09-24 05:11:581// Copyright (c) 2009 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 CHROME_FRAME_NPAPI_URL_REQUEST_H_
6#define CHROME_FRAME_NPAPI_URL_REQUEST_H_
7
[email protected]3eb07da2010-02-01 19:48:368#include <map>
9
[email protected]f7817822009-09-24 05:11:5810#include "base/platform_thread.h"
11#include "chrome_frame/plugin_url_request.h"
12#include "third_party/WebKit/WebCore/bridge/npapi.h"
13
[email protected]3eb07da2010-02-01 19:48:3614class NPAPIUrlRequest;
15class NPAPIUrlRequestManager : public PluginUrlRequestManager,
16 public PluginUrlRequestDelegate {
[email protected]f7817822009-09-24 05:11:5817 public:
[email protected]3eb07da2010-02-01 19:48:3618 NPAPIUrlRequestManager();
19 ~NPAPIUrlRequestManager();
[email protected]f7817822009-09-24 05:11:5820
[email protected]3eb07da2010-02-01 19:48:3621 void set_NPPInstance(NPP instance) {
22 instance_ = instance;
23 }
[email protected]f7817822009-09-24 05:11:5824
[email protected]3eb07da2010-02-01 19:48:3625 // Notifications from the browser. We find the appropriate NPAPIUrlRequest
26 // and forward the call.
[email protected]0d9d45132010-02-02 00:04:2827 NPError NewStream(NPMIMEType type, NPStream* stream,
28 NPBool seekable, uint16* stream_type);
[email protected]3eb07da2010-02-01 19:48:3629 int32 WriteReady(NPStream* stream);
30 int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer);
31 NPError DestroyStream(NPStream* stream, NPReason reason);
32 void UrlNotify(const char* url, NPReason reason, void* notify_data);
[email protected]f7817822009-09-24 05:11:5833
34 private:
[email protected]3eb07da2010-02-01 19:48:3635 // PluginUrlRequestManager implementation. Called from AutomationClient.
36 virtual bool IsThreadSafe();
37 virtual void StartRequest(int request_id,
38 const IPC::AutomationURLRequest& request_info);
39 virtual void ReadRequest(int request_id, int bytes_to_read);
40 virtual void EndRequest(int request_id);
41 virtual void StopAll();
[email protected]f7817822009-09-24 05:11:5842
[email protected]3eb07da2010-02-01 19:48:3643 // Outstanding requests map.
44 typedef std::map<int, scoped_refptr<NPAPIUrlRequest> > RequestMap;
45 RequestMap request_map_;
46
[email protected]0d9d45132010-02-02 00:04:2847 scoped_refptr<NPAPIUrlRequest> LookupRequest(int request_id);
48
[email protected]3eb07da2010-02-01 19:48:3649 // PluginUrlRequestDelegate implementation. Forwards back to delegate.
50 virtual void OnResponseStarted(int request_id, const char* mime_type,
[email protected]70daf0b2010-03-02 19:13:0051 const char* headers, int size, base::Time last_modified,
[email protected]3eb07da2010-02-01 19:48:3652 const std::string& redirect_url, int redirect_status);
53 virtual void OnReadComplete(int request_id, const void* buffer, int len);
54 virtual void OnResponseEnd(int request_id, const URLRequestStatus& status);
55
56 static inline NPAPIUrlRequest* RequestFromNotifyData(void* notify_data) {
57 return reinterpret_cast<NPAPIUrlRequest*>(notify_data);
58 }
59
60 NPP instance_;
[email protected]f7817822009-09-24 05:11:5861};
62
63#endif // CHROME_FRAME_NPAPI_URL_REQUEST_H_
64