Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: chrome_frame/chrome_frame_npapi_entrypoints.cc

Issue 545093: Refactor host network (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_frame_npapi.cc ('k') | chrome_frame/http_negotiate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome_frame/chrome_frame_npapi_entrypoints.h" 5 #include "chrome_frame/chrome_frame_npapi_entrypoints.h"
6 #include "chrome_frame/chrome_frame_npapi.h" 6 #include "chrome_frame/chrome_frame_npapi.h"
7 7
8 #define NPAPI WINAPI 8 #define NPAPI WINAPI
9 9
10 // Plugin entry points. 10 // Plugin entry points.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (plugin_instance == NULL) { 112 if (plugin_instance == NULL) {
113 return NPERR_INVALID_INSTANCE_ERROR; 113 return NPERR_INVALID_INSTANCE_ERROR;
114 } 114 }
115 115
116 plugin_instance->SetWindow(window_info); 116 plugin_instance->SetWindow(window_info);
117 return NPERR_NO_ERROR; 117 return NPERR_NO_ERROR;
118 } 118 }
119 119
120 NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, 120 NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
121 NPBool seekable, uint16* stream_type) { 121 NPBool seekable, uint16* stream_type) {
122 NPAPIUrlRequest* url_request = ChromeFrameNPAPI::ValidateRequest( 122 ChromeFrameNPAPI* plugin_instance =
123 instance, stream->notifyData); 123 ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
124 if (url_request) { 124 if (plugin_instance == NULL) {
125 if (!url_request->OnStreamCreated(type, stream)) 125 return NPERR_INVALID_INSTANCE_ERROR;
126 return NPERR_GENERIC_ERROR;
127 } 126 }
128 127
129 // We need to return the requested stream mode if we are returning a success 128 return plugin_instance->NewStream(type, stream, seekable, stream_type);
130 // code. If we don't do this it causes Opera to blow up.
131 *stream_type = NP_NORMAL;
132 return NPERR_NO_ERROR;
133 } 129 }
134 130
135 NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) { 131 NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) {
136 NPAPIUrlRequest* url_request = ChromeFrameNPAPI::ValidateRequest( 132 ChromeFrameNPAPI* plugin_instance =
137 instance, stream->notifyData); 133 ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
138 if (url_request) { 134 if (plugin_instance == NULL) {
139 url_request->OnStreamDestroyed(reason); 135 return NPERR_INVALID_INSTANCE_ERROR;
140 } 136 }
141 137
142 return NPERR_NO_ERROR; 138 return plugin_instance->DestroyStream(stream, reason);
143 } 139 }
144 140
145 NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) { 141 NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
146 if (variable == NPPVpluginScriptableNPObject) { 142 if (variable == NPPVpluginScriptableNPObject) {
147 void** plugin = reinterpret_cast<void**>(value); 143 void** plugin = reinterpret_cast<void**>(value);
148 ChromeFrameNPAPI::ChromeFrameNPObject* chrome_frame_npapi_obj = 144 ChromeFrameNPAPI::ChromeFrameNPObject* chrome_frame_npapi_obj =
149 reinterpret_cast<ChromeFrameNPAPI::ChromeFrameNPObject*>( 145 reinterpret_cast<ChromeFrameNPAPI::ChromeFrameNPObject*>(
150 instance->pdata); 146 instance->pdata);
151 // Return value is expected to be retained 147 // Return value is expected to be retained
152 npapi::RetainObject(reinterpret_cast<NPObject*>(chrome_frame_npapi_obj)); 148 npapi::RetainObject(reinterpret_cast<NPObject*>(chrome_frame_npapi_obj));
153 *plugin = chrome_frame_npapi_obj; 149 *plugin = chrome_frame_npapi_obj;
154 return NPERR_NO_ERROR; 150 return NPERR_NO_ERROR;
155 } 151 }
156 return NPERR_GENERIC_ERROR; 152 return NPERR_GENERIC_ERROR;
157 } 153 }
158 154
159 NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) { 155 NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
160 return NPERR_GENERIC_ERROR; 156 return NPERR_GENERIC_ERROR;
161 } 157 }
162 158
163 int32 NPP_WriteReady(NPP instance, NPStream* stream) { 159 int32 NPP_WriteReady(NPP instance, NPStream* stream) {
164 static const int kMaxBytesForPluginConsumption = 0x7FFFFFFF; 160 static const int kMaxBytesForPluginConsumption = 0x7FFFFFFF;
165 161
166 NPAPIUrlRequest* url_request = ChromeFrameNPAPI::ValidateRequest( 162 ChromeFrameNPAPI* plugin_instance =
167 instance, stream->notifyData); 163 ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
168 if (url_request) { 164
169 return url_request->OnWriteReady(); 165 if (plugin_instance == NULL) {
166 return kMaxBytesForPluginConsumption;
170 } 167 }
171 168
172 return kMaxBytesForPluginConsumption; 169 return plugin_instance->WriteReady(stream);
173 } 170 }
174 171
175 int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, 172 int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
176 void* buffer) { 173 void* buffer) {
177 NPAPIUrlRequest* url_request = ChromeFrameNPAPI::ValidateRequest( 174 ChromeFrameNPAPI* plugin_instance =
178 instance, stream->notifyData); 175 ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
179 if (url_request) {
180 return url_request->OnWrite(buffer, len);
181 }
182 176
183 return len; 177 if (plugin_instance == NULL)
178 return len;
179
180 return plugin_instance->Write(stream, offset, len, buffer);
184 } 181 }
185 182
186 void NPP_URLNotify(NPP instance, const char* url, NPReason reason, 183 void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
187 void* notifyData) { 184 void* notifyData) {
188 ChromeFrameNPAPI* plugin_instance = 185 ChromeFrameNPAPI* plugin_instance =
189 ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance); 186 ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
190 if (plugin_instance) { 187 if (plugin_instance) {
191 plugin_instance->UrlNotify(url, reason, notifyData); 188 plugin_instance->UrlNotify(url, reason, notifyData);
192 } 189 }
193 } 190 }
194 191
195 void NPP_Print(NPP instance, NPPrint* print_info) { 192 void NPP_Print(NPP instance, NPPrint* print_info) {
196 ChromeFrameNPAPI* plugin_instance = 193 ChromeFrameNPAPI* plugin_instance =
197 ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance); 194 ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
198 195
199 if (plugin_instance == NULL) { 196 if (plugin_instance == NULL) {
200 NOTREACHED(); 197 NOTREACHED();
201 return; 198 return;
202 } 199 }
203 200
204 plugin_instance->Print(print_info); 201 plugin_instance->Print(print_info);
205 } 202 }
206 203
207 } // namespace chrome_frame 204 } // namespace chrome_frame
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame_npapi.cc ('k') | chrome_frame/http_negotiate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698