Browse Source

move request_ready into PPInstance

David Rose 16 years ago
parent
commit
e71220779c

+ 43 - 1
direct/src/plugin_npapi/ppInstance.cxx

@@ -445,7 +445,7 @@ handle_request(P3D_request *request) {
 
 ////////////////////////////////////////////////////////////////////
 //     Function: PPInstance::handle_request_loop
-//       Access: Public, Static
+//       Access: Private, Static
 //  Description: Checks for any new requests from the plugin, and
 //               dispatches them to the appropriate PPInstance.  This
 //               function is called only in the main thread.
@@ -582,6 +582,48 @@ variant_to_p3dobj(const NPVariant *variant) {
   return P3D_new_none_object();
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PPInstance::request_ready
+//       Access: Private, Static
+//  Description: This function is attached as an asynchronous callback
+//               to each instance; it will be notified when the
+//               instance has a request ready.  This function may be
+//               called in a sub-thread.
+////////////////////////////////////////////////////////////////////
+void PPInstance::
+request_ready(P3D_instance *instance) {
+  logfile
+    << "request_ready in " << instance
+    //    << " thread = " << GetCurrentThreadId()
+    << "\n" << flush;
+
+#ifdef _WIN32
+  // Since we might be in a sub-thread at this point, use a Windows
+  // message to forward this event to the main thread.
+
+  // Get the window handle for the window associated with this
+  // instance.
+  PPInstance *inst = (PPInstance *)(instance->_user_data);
+  assert(inst != NULL);
+  const NPWindow *win = inst->get_window();
+  if (win != NULL && win->type == NPWindowTypeWindow) {
+    PostMessage((HWND)(win->window), WM_USER, 0, 0);
+  }
+
+#else
+  // On Mac, we ignore this asynchronous event, and rely on detecting
+  // it within HandleEvent().  TODO: enable a timer to ensure we get
+  // HandleEvent callbacks in a timely manner?  Or maybe we should
+  // enable a one-shot timer in response to this asynchronous event?
+  
+#ifndef __APPLE__
+  // On Unix, HandleEvent isn't called, so we will do what it does
+  // right here. Not sure if this is right.
+  handle_request_loop();
+#endif  // __APPLE__
+#endif  // _WIN32
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PPInstance::start_download
 //       Access: Private

+ 2 - 0
direct/src/plugin_npapi/ppInstance.h

@@ -61,6 +61,8 @@ public:
   static void output_np_variant(ostream &out, const NPVariant &result);
 
 private:
+  static void request_ready(P3D_instance *instance);
+
   void start_download(const string &url, PPDownloadRequest *req);
   void downloaded_file(PPDownloadRequest *req, const string &filename);
   static string get_filename_from_url(const string &url);

+ 0 - 41
direct/src/plugin_npapi/startup.cxx

@@ -34,47 +34,6 @@ open_logfile() {
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: request_ready
-//  Description: This function is attached as an asynchronous callback
-//               to each instance; it will be notified when the
-//               instance has a request ready.  This function may be
-//               called in a sub-thread.
-////////////////////////////////////////////////////////////////////
-void
-request_ready(P3D_instance *instance) {
-  logfile
-    << "request_ready in " << instance
-    //    << " thread = " << GetCurrentThreadId()
-    << "\n" << flush;
-
-#ifdef _WIN32
-  // Since we might be in a sub-thread at this point, use a Windows
-  // message to forward this event to the main thread.
-
-  // Get the window handle for the window associated with this
-  // instance.
-  PPInstance *inst = (PPInstance *)(instance->_user_data);
-  assert(inst != NULL);
-  const NPWindow *win = inst->get_window();
-  if (win != NULL && win->type == NPWindowTypeWindow) {
-    PostMessage((HWND)(win->window), WM_USER, 0, 0);
-  }
-
-#else
-  // On Mac, we ignore this asynchronous event, and rely on detecting
-  // it within HandleEvent().  TODO: enable a timer to ensure we get
-  // HandleEvent callbacks in a timely manner?  Or maybe we should
-  // enable a one-shot timer in response to this asynchronous event?
-  
-#ifndef __APPLE__
-  // On Unix, HandleEvent isn't called, so we will do what it does
-  // right here. Not sure if this is right.
-  PPInstance::handle_request_loop();
-#endif  // __APPLE__
-#endif  // _WIN32
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: NP_GetMIMEDescription
 //  Description: On Unix, this function is called by the browser to