WebBaseNetscapePluginStream.h 5.71 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer. 
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution. 
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 *     its contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
ddkilzer@apple.com's avatar
ddkilzer@apple.com committed
28
29

#if ENABLE(NETSCAPE_PLUGIN_API)
30
31
#import <Foundation/Foundation.h>

32
33
#import <WebCore/Timer.h>
#import <WebCore/NetscapePlugInStreamLoader.h>
rjw's avatar
rjw committed
34
#import <WebKit/npfunctions.h>
35
#import <WebKit/WebPlugInStreamLoaderDelegate.h>
36
#import <wtf/PassRefPtr.h>
37
38
#import <wtf/RefCounted.h>
#import <wtf/RefPtr.h>
39
#import <wtf/RetainPtr.h>
40

andersca@apple.com's avatar
WebKit:    
andersca@apple.com committed
41
42
43
44
45
46
47
namespace WebCore {
    class FrameLoader;
    class NetscapePlugInStreamLoader;
}

class WebNetscapePlugInStreamLoaderClient;

tomernic's avatar
tomernic committed
48
@class WebBaseNetscapePluginView;
kocienda's avatar
Tests:    
kocienda committed
49
@class NSURLResponse;
50
@class WebBaseNetscapePluginStream;
51

52
class WebNetscapePluginStream : public RefCounted<WebNetscapePluginStream>
53
                              , private WebCore::NetscapePlugInStreamLoaderClient
54
55
{
public:
56
    static PassRefPtr<WebNetscapePluginStream> create(WebBaseNetscapePluginStream *stream, NSURLRequest *request, NPP plugin, bool sendNotification, void* notifyData)
57
    {
58
        return adoptRef(new WebNetscapePluginStream(stream, request, plugin, sendNotification, notifyData));
59
    }
60
61
62
63
64
    static PassRefPtr<WebNetscapePluginStream> create(WebBaseNetscapePluginStream *stream, WebCore::FrameLoader* frameLoader)
    {
        return adoptRef(new WebNetscapePluginStream(stream, frameLoader));
    }

65
66
    virtual ~WebNetscapePluginStream() { }

67
    NPP plugin() const { return m_plugin; }
68
69
    void setPlugin(NPP);
    
70
71
    static NPP ownerForStream(NPStream *);

72
    static NPReason reasonForError(NSError *);
73
74
75
    NSError *errorForReason(NPReason) const;

    void cancelLoadAndDestroyStreamWithError(NSError *);
76

77
78
79
80
81
82
83
    void setRequestURL(NSURL *requestURL) { m_requestURL = requestURL; }

    void start();
    void stop();
    
    void startStreamWithResponse(NSURLResponse *response);
    
84
85
    // FIXME: These should all be private once WebBaseNetscapePluginStream is history...
public:
86
    void destroyStream();
87
88
89
    void cancelLoadWithError(NSError *);
    void destroyStreamWithError(NSError *);
    void destroyStreamWithReason(NPReason);
90
91
92
    void deliverDataToFile(NSData *data);
    void deliverData();

93
94
    void startStream(NSURL *, long long expectedContentLength, NSDate *lastModifiedDate, NSString *mimeType, NSData *headers);
    
95
    NSError *pluginCancelledConnectionError() const;
96

97
98
99
100
101
102
103
    // NetscapePlugInStreamLoaderClient methods.
    void didReceiveResponse(WebCore::NetscapePlugInStreamLoader*, const WebCore::ResourceResponse&);
    void didReceiveData(WebCore::NetscapePlugInStreamLoader*, const char* bytes, int length);
    void didFail(WebCore::NetscapePlugInStreamLoader*, const WebCore::ResourceError&);
    void didFinishLoading(WebCore::NetscapePlugInStreamLoader*);
    bool wantsAllStreams() const;

104
105
106
107
108
    RetainPtr<NSMutableData> m_deliveryData;
    RetainPtr<NSURL> m_requestURL;
    RetainPtr<NSURL> m_responseURL;
    RetainPtr<NSString> m_mimeType;

109
110
111
112
113
114
115
116
    NPP m_plugin;
    uint16 m_transferMode;
    int32 m_offset;
    NPStream m_stream;
    RetainPtr<NSString> m_path;
    int m_fileDescriptor;
    BOOL m_sendNotification;
    void *m_notifyData;
117
118
119
120
121
    char *m_headers;
    RetainPtr<WebBaseNetscapePluginView> m_pluginView;
    NPReason m_reason;
    bool m_isTerminated;
    bool m_newStreamSuccessful;
122
    
123
124
125
126
127
128
    WebCore::FrameLoader* m_frameLoader;
    WebCore::NetscapePlugInStreamLoader* m_loader;
    WebNetscapePlugInStreamLoaderClient* m_client;
    NSURLRequest *m_request;
    NPPluginFuncs *m_pluginFuncs;

129
130
131
    void deliverDataTimerFired(WebCore::Timer<WebNetscapePluginStream>* timer);
    WebCore::Timer<WebNetscapePluginStream> m_deliverDataTimer;
    
132
133
134
    // FIXME: Remove this once it's not needed anymore.
    WebBaseNetscapePluginStream *m_pluginStream;
    
135
private:
136
137
    WebNetscapePluginStream(WebBaseNetscapePluginStream *, WebCore::FrameLoader*);
    WebNetscapePluginStream(WebBaseNetscapePluginStream *, NSURLRequest *, NPP, bool sendNotification, void* notifyData);
138
139
};

mjs's avatar
mjs committed
140
@interface WebBaseNetscapePluginStream : NSObject<WebPlugInStreamLoaderDelegate>
141
{     
142
    RefPtr<WebNetscapePluginStream> _impl;
143
144
}

145
- (WebNetscapePluginStream *)impl;
146

andersca@apple.com's avatar
WebKit:    
andersca@apple.com committed
147
148
149
150
151
152
153
- (id)initWithFrameLoader:(WebCore::FrameLoader *)frameLoader;

- (id)initWithRequest:(NSURLRequest *)theRequest
               plugin:(NPP)thePlugin
           notifyData:(void *)theNotifyData
     sendNotification:(BOOL)sendNotification;

154
@end
kdecker's avatar
kdecker committed
155
#endif