************************* G4 reminder *************************
These new files:

        
c:\MyDocs\Gears3\googleclient\gears\opensource\gears\base\opera\opera_utils.cc

are missing unit tests.
***************************************************************

Hello andreip,

I'd like you to do a code review.  Please execute
        g4 diff -c 9135600

or point your web browser to
        http://mondrian/9135600

to review the following code:

Change 9135600 by [EMAIL PROTECTED] on 2008/11/24 16:53:02 *pending*

        Adds the Opera Mobile browser API headers and the OperaUtils class for 
accessing this API.
        
        R=andreip
        [EMAIL PROTECTED],[EMAIL PROTECTED]
        DELTA=505  (504 added, 0 deleted, 1 changed)
        OCL=9135600

Affected files ...

... //depot/googleclient/gears/opensource/gears/Makefile#215 edit
... //depot/googleclient/gears/opensource/gears/base/npapi/module.cc#7 edit
... //depot/googleclient/gears/opensource/gears/base/npapi/module.h#6 edit
... //depot/googleclient/gears/opensource/gears/base/opera/opera_utils.cc#1 add
... //depot/googleclient/gears/opensource/gears/base/opera/opera_utils.h#1 add
... 
//depot/googleclient/gears/opensource/third_party/opera/opera_callback_api.h#1 
add
... 
//depot/googleclient/gears/opensource/third_party/opera/opera_local_server_interface.h#1
 add
... 
//depot/googleclient/gears/opensource/third_party/opera/opera_worker_interface.h#1
 add

505 delta lines: 504 added, 0 deleted, 1 changed

Also consider running:
        g4 lint -c 9135600

which verifies that the changelist doesn't introduce new style violations.

If you can't do the review, please let me know as soon as possible.  During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately.  Visit
http://www/eng/code_review.html for more information.

This is a semiautomated message from "g4 mail".  Complaints or suggestions?
Mail [EMAIL PROTECTED]
Change 9135600 by [EMAIL PROTECTED] on 2008/11/24 16:53:02 *pending*

        Adds the Opera Mobile browser API headers and the OperaUtils class for 
accessing this API.
        
        R=andreip
        [EMAIL PROTECTED],[email protected]
        DELTA=377  (374 added, 0 deleted, 3 changed)
        OCL=9135600

Affected files ...

... //depot/googleclient/gears/opensource/gears/Makefile#215 edit
... //depot/googleclient/gears/opensource/gears/base/npapi/module.cc#7 edit
... //depot/googleclient/gears/opensource/gears/base/npapi/module.h#6 edit
... //depot/googleclient/gears/opensource/gears/base/opera/opera_utils.cc#1 add
... //depot/googleclient/gears/opensource/gears/base/opera/opera_utils.h#1 add
... 
//depot/googleclient/gears/opensource/third_party/opera/opera_callback_api.h#1 
add
... 
//depot/googleclient/gears/opensource/third_party/opera/opera_local_server_interface.h#1
 add
... 
//depot/googleclient/gears/opensource/third_party/opera/opera_worker_interface.h#1
 add

==== //depot/googleclient/gears/opensource/gears/Makefile#215 - 
c:\MyDocs\Gears3/googleclient/gears/opensource/gears/Makefile ====
# action=edit type=text
--- googleclient/gears/opensource/gears/Makefile        2008-11-27 
18:12:17.000000000 +0000
+++ googleclient/gears/opensource/gears/Makefile        2008-11-27 
18:12:20.000000000 +0000
@@ -1199,6 +1199,7 @@
                detect_version_collision_win32.cc \
                message_queue_win32.cc \
                js_standalone_engine_op.cc \
+               opera_utils.cc \
                paths_op.cc \
                $(NULL)
 
==== //depot/googleclient/gears/opensource/gears/base/npapi/module.cc#7 - 
c:\MyDocs\Gears3/googleclient/gears/opensource/gears/base/npapi/module.cc ====
# action=edit type=text
--- googleclient/gears/opensource/gears/base/npapi/module.cc    2008-11-10 
14:29:58.000000000 +0000
+++ googleclient/gears/opensource/gears/base/npapi/module.cc    2008-11-27 
18:12:22.000000000 +0000
@@ -47,12 +47,17 @@
 #include "gears/base/safari/npapi_patches.h" 
 #endif
 #include "gears/base/npapi/module.h"
+#ifdef BROWSER_OPERA
+#include "gears/base/npapi/plugin.h"
+#include "gears/base/opera/opera_utils.h"
+#include "third_party/opera/opera_callback_api.h"
+#endif  // BROWSER_OPERA
 
 #ifndef HIBYTE
 #define HIBYTE(x) ((((uint32)(x)) & 0xff00) >> 8)
 #endif
 
-#ifdef BROWSER_WEBKIT
+#if defined(BROWSER_WEBKIT) || defined(BROWSER_OPERA)
 static bool g_allow_npinit = true;
 #else
 static bool g_allow_npinit = false;
@@ -185,6 +190,20 @@
 }
 #endif
 
+#ifdef BROWSER_OPERA
+void OP_Initialize(OpGearsAPI *opera_instance, OperaCallbacks *callbacks) {
+  LOG16((L"OP_Initialize called\n"));
+
+  OperaUtils::Init(opera_instance, 
ThreadMessageQueue::GetInstance()->GetCurrentThreadId());
+
+  callbacks->create_worker = OperaUtils::CreateWorkerThread;
+  // TODO([EMAIL PROTECTED]): Provide a CloneObject method.
+  //callbacks->clone_object = PluginBase::CloneObject;;
+  callbacks->open_settings_dialog = OperaUtils::OpenSettingsDialog;
+  // TODO([EMAIL PROTECTED]): Provide a OperaLocalServerImpl::Create method.
+  //callbacks->local_server_init = OperaLocalServerImpl::Create;
+}
+#endif  // BROWSER_OPERA
 
 #ifdef WIN32
 BOOL MyDllMain(HANDLE instance, DWORD reason, LPVOID reserved) {
==== //depot/googleclient/gears/opensource/gears/base/npapi/module.h#6 - 
c:\MyDocs\Gears3/googleclient/gears/opensource/gears/base/npapi/module.h ====
# action=edit type=text
--- googleclient/gears/opensource/gears/base/npapi/module.h     2008-11-10 
14:29:58.000000000 +0000
+++ googleclient/gears/opensource/gears/base/npapi/module.h     2008-11-27 
18:12:25.000000000 +0000
@@ -38,4 +38,11 @@
 // js_runner_np.cc.
 void NotifyNPInstanceDestroyed(NPP instance);
 
+#ifdef BROWSER_OPERA
+class OpGearsAPI;
+struct OperaCallbacks;
+// exported function to do initialization from the Opera browser
+extern "C" __declspec(dllexport) void OP_Initialize(OpGearsAPI 
*opera_instance, OperaCallbacks *callbacks);
+#endif  // BROWSER_OPERA
+
 #endif  // GEARS_BASE_NPAPI_MODULE_H__
==== //depot/googleclient/gears/opensource/gears/base/opera/opera_utils.cc#1 - 
c:\MyDocs\Gears3/googleclient/gears/opensource/gears/base/opera/opera_utils.cc 
====
# action=add type=text
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ googleclient/gears/opensource/gears/base/opera/opera_utils.cc       
2008-11-27 18:12:27.000000000 +0000
@@ -0,0 +1,135 @@
+// Copyright 2008, Google Inc.
+//
+// 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 Google Inc. 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 THE AUTHOR ``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 THE AUTHOR 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.
+
+#include "gears/base/opera/opera_utils.h"
+
+#include <assert.h>
+
+#include "third_party/opera/opera_callback_api.h"
+#include "third_party/opera/opera_worker_interface.h"
+
+#include "gears/base/npapi/module_wrapper.h"
+#include "gears/factory/factory_np.h"
+#include "gears/factory/factory_impl.h"
+#include "gears/ui/common/settings_dialog.h"
+
+
+// Implementation of the wrapper class for the native opera worker threads
+class OperaWorkerThreadImpl
+ : public OperaWorkerThreadInterface {
+ public:
+
+  OperaWorkerThreadImpl() : js_runner_(NULL) {
+       factory_.reset(NULL);
+  }
+
+  virtual ~OperaWorkerThreadImpl() {
+       factory_.reset(NULL);
+       delete js_runner_;
+  }
+
+  virtual void Destroy() {
+       delete this;
+  }
+
+  virtual NPObject* CreateWorkerFactory(NPP instance, NPObject* global_object,
+                                                                               
const unsigned short* url) {
+       // TODO([EMAIL PROTECTED]): Initialise the JsRunner.
+  //if (!js_runner_)
+       //  js_runner_ = NewJsRunner(instance, global_object);
+       if (!js_runner_)
+         return NULL;
+
+       if (!factory_.get()) {
+         SecurityOrigin security_origin;
+         scoped_refptr<BrowsingContext> browsing_context;
+         if (!security_origin.InitFromUrl(url))
+               return NULL;
+         BrowserUtils::GetPageBrowsingContext((NPP)instance, 
&browsing_context);
+       
+         ModuleEnvironment* module_env =
+               new ModuleEnvironment(security_origin,
+                                                         true, js_runner_,
+                                                         
browsing_context.get());
+         if (!module_env)
+               return NULL;
+
+         if (!CreateModule<GearsFactoryImpl>(module_env, 
(JsCallContext*)instance, &factory_)) { return NULL; }
+       }
+
+       if (!NPVARIANT_IS_OBJECT(factory_.get()->GetWrapperToken()))
+         return NULL;
+       NPObject* fo = NPVARIANT_TO_OBJECT(factory_.get()->GetWrapperToken());
+       NPN_RetainObject(fo);
+         
+       return fo;
+  }
+
+  virtual void SuspendObjectCreation() {
+       if (factory_.get())
+         factory_.get()->SuspendObjectCreation();
+  }
+
+  virtual void ResumeObjectCreationAndUpdatePermissions() {
+       if (factory_.get())
+         factory_.get()->ResumeObjectCreationAndUpdatePermissions();
+  }
+
+ private:
+  JsRunnerInterface* js_runner_;
+  scoped_refptr<GearsFactoryImpl> factory_;
+};
+
+OpGearsAPI* OperaUtils::opera_api_ = NULL;
+ThreadId OperaUtils::browser_thread_ = 0;
+
+//static
+void OperaUtils::Init(OpGearsAPI* opera_api, ThreadId browser_thread) {
+  opera_api_ = opera_api;
+  browser_thread_ = browser_thread;
+}
+
+// static
+OpGearsAPI* OperaUtils::GetBrowserApiForGears() {
+  assert(opera_api_ != NULL);
+  return opera_api_;
+}
+
+// static
+ThreadId OperaUtils::GetBrowserThreadId() {
+  assert(browser_thread_ != NULL);
+  return browser_thread_;
+}
+
+// static
+OperaWorkerThreadInterface* OperaUtils::CreateWorkerThread() {
+  OperaWorkerThreadImpl* opw = new OperaWorkerThreadImpl();
+  return opw;
+}
+
+// static
+void OperaUtils::OpenSettingsDialog() {
+  SettingsDialog::Run(NULL);
+}
==== //depot/googleclient/gears/opensource/gears/base/opera/opera_utils.h#1 - 
c:\MyDocs\Gears3/googleclient/gears/opensource/gears/base/opera/opera_utils.h 
====
# action=add type=text
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ googleclient/gears/opensource/gears/base/opera/opera_utils.h        
2008-11-27 18:12:29.000000000 +0000
@@ -0,0 +1,66 @@
+// Copyright 2008, Google Inc.
+//
+// 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 Google Inc. 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 THE AUTHOR ``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 THE AUTHOR 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.
+//
+// This class contains convenience functions used by the Opera implementation
+// of the plugin. It holds the pointer to the API exported by Opera.
+//
+
+#ifndef GEARS_BASE_OPERA_OPERA_UTILS_H__
+#define GEARS_BASE_OPERA_OPERA_UTILS_H__
+
+#include "gears/base/common/message_queue.h"  // for ThreadId
+
+class OpGearsAPI;
+class OperaWorkerThreadInterface;
+
+class OperaUtils {
+ public:
+  // Called when Opera first loads Gears. opera_api points to an object
+  // that implements the Opera API for Gears. browser_thread must be
+  // set to the ID of the thread Opera runs on.
+  static void Init(OpGearsAPI* opera_api, ThreadId browser_thread);
+
+  // Returns the pointer to the Opera API for Gears.
+  static OpGearsAPI* GetBrowserApiForGears();
+
+  // Returns the ID of the thread the browser runs on.
+  static ThreadId GetBrowserThreadId();
+
+  // Creates and returns a handle to an Opera worker thread.
+  static OperaWorkerThreadInterface* CreateWorkerThread();
+
+  // Called to open the Gears settings dialog.
+  static void OpenSettingsDialog();
+
+ private:
+  // Holds the pointer to the global Opera API for Gears.
+  static OpGearsAPI* opera_api_;
+  // Holds the ID of the thread the browser runs on.
+  static ThreadId browser_thread_;
+
+  DISALLOW_EVIL_CONSTRUCTORS(OperaUtils);
+};
+
+#endif  // GEARS_BASE_OPERA_OPERA_UTILS_H__
==== 
//depot/googleclient/gears/opensource/third_party/opera/opera_callback_api.h#1 
- 
c:\MyDocs\Gears3/googleclient/gears/opensource/third_party/opera/opera_callback_api.h
 ====
# action=add type=text
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ googleclient/gears/opensource/third_party/opera/opera_callback_api.h        
2008-11-27 18:12:31.000000000 +0000
@@ -0,0 +1,185 @@
+#ifndef OPERA_CALLBACK_API_H__
+#define OPERA_CALLBACK_API_H__
+
+#include "third_party/npapi/npapi.h" // for NPP
+
+struct NPObject;
+struct OperaCallbacks;
+class OpGearsAPI;
+class OperaWorkerThreadInterface;
+class OpLocalServerInterface;
+
+// Struct containing function pointers used to hold callback functions
+// from Opera to Gears.
+struct OperaCallbacks {
+  typedef void (*InitializeFunc)(OpGearsAPI *, OperaCallbacks *);
+  typedef OperaWorkerThreadInterface* (*CreateWorkerFunc)();
+  typedef NPObject* (*CloneObjectFunc)(NPObject *object);
+  typedef void (*OpenSettingsDialogFunc)();
+  typedef void (*LocalServerInitializeFunc)
+          (OpLocalServerInterface **opera_local_server_instance);
+
+  // Functions called by Opera when a worker thread is created.
+  CreateWorkerFunc create_worker;
+  // Functions called by Opera when an object is cloned in a worker thread.
+  CloneObjectFunc clone_object;
+  // Functions called by Opera to open the Gears settings dialog.
+  OpenSettingsDialogFunc open_settings_dialog;
+  // Functions called by Opera to initialize the URL data storage.
+  LocalServerInitializeFunc local_server_init;
+};
+
+// This interface is used by Opera to get the data from Gears needed
+// when requesting a URL.
+class OpHTTPRequestDataProviderInterface {
+ public:
+  // Returns true if the request is supposed to be asynchronous.
+  virtual bool IsAsync() = 0;
+  // Called repeatedly to iterate through the headers explicitly set by the
+  // Gears code for this request. As long as the funtion returns true name
+  // and value will hold the name/value pair of the header.
+  virtual bool GetNextReqHeader(const unsigned short *&name,
+                                                                const unsigned 
short *&value) = 0;
+  // Returns the URL string for the request.
+  virtual const unsigned short*        GetUrl() = 0;
+
+  // Returns the HTTP method string for the request.
+  virtual const unsigned short*        GetMethod() = 0;
+  // Only applicable if the method is POST. Returns either the length of
+  // the post data or copies chunks of the actual post data.
+  // If called with max_size set to -1 it will return the length of the
+  // data to be posted.
+  // If called with a buffer pointing to a preallocated buffer and the
+  // length of the buffer in max_size, the actual data to be posted will be
+  // copied to the buffer. Returns the amount of data copied to the buffer.
+  // Must be called until it returns a length less than max_size.
+  virtual long                             GetPostData(unsigned char* buffer,
+                                                                               
                long max_size) = 0;
+};
+
+// This interface is used by the Opera implementation of the Gears code to
+// return the data fetched by Opera after a HTTP request.
+class OpUrlData {
+ public:
+  // Returns the HTTP status code
+  virtual unsigned int GetStatus() = 0;
+  // After calling, status will contain a pointer to the HTTP status text
+  virtual void    GetStatusText(const char *&status) = 0;
+  // After calling, content will contain a non-terminated buffer of the
+  // data from the requested URL. content_length will hold the length
+  // of the data in the content buffer.
+  virtual void GetBodyText(const char *&content,
+                                                       unsigned long 
&content_length) = 0;
+  // After calling, a continous 0-erminated string of the headers returned
+  // from the server separated by linebreaks.
+  virtual void GetResponseHeaders(const char *&headers) = 0;
+  // After calling, charset will contain the character set specified from
+  // the server as a string.
+  virtual void GetResponseCharset(const char *&charset) = 0;
+  // Returns true if the loading of the URL is completed.
+  virtual bool IsFinished() = 0;
+  // Called by the Gears code when it is finished processing the URL data.
+  virtual void OnCompleted() = 0;
+};
+
+// Listener interface for callbacks during loading of a URL requested from
+// the Gears code.
+class OpHTTPListener {
+ public:
+  // Constants returned from Gears when OnRedirected is called.
+  // OK if we should redirect, CANCEL if not.
+  enum RedirectStatus {
+    REDIRECT_STATUS_OK,
+    REDIRECT_STATUS_CANCEL
+  };
+
+  // Constants for error codes sent to Gears in an OnError() call.
+  enum LoadingError {
+    LOADING_ERROR_GENERIC,
+    LOADING_ERROR_OUT_OF_MEMORY
+  };
+
+  // Called when a chunk of data is received from the server. Will be called
+  // repeatedly until the URL is finished loading.
+  virtual void                 OnDataReceived() = 0;
+  // Called when the URL is redirected. The new URL string will be in
+  // redirect_url. Return REDIRECT_OK if we should redirect to the new URL
+  // or REDIRECT_CANCEL if we should not.
+  virtual RedirectStatus       OnRedirected(const unsigned short* 
redirect_url) = 0;
+  // Called when an error occurs during loading of the URL. err will hold the
+  // error code.
+  virtual void                 OnError(LoadingError err) = 0;
+  // This will be called back from Opera immediately when the an HTTP request
+  // has been made from Gears. It will contain a pointer to the an object
+  // implementing the OpUrlData interface.
+  virtual void                 OnRequestCreated(OpUrlData* data) = 0;
+  // This will be called once when the request in Opera is deleted for some
+  // reason, for instance when we are finished.
+  virtual void                 OnRequestDestroyed() = 0;
+};
+
+// Listener interface for callbacks during the display of a dialog requested
+// by the Gears code.
+class OpDialogListener {
+ public:
+  // Called when the user closes the dialog. A pointer to the result string
+  // will be in result.
+  virtual void OnClose(const unsigned short *result) = 0;
+};
+
+// The interface between Opera and Gears. Gears will call one of these
+// functions when it wants Opera to perform a specific task.
+class OpGearsAPI {
+ public:
+  // Request Opera to load a URL.
+  // plugin_instance must contain the plugin object from the NPAPI invocation.
+  // It is used internally in Opera to identify the document context which the
+  // URL should be loaded in.
+  // req_data must point to an implementation of the
+  // OpHTTPRequestDataProviderInterface that will deliver the information
+  // about the URL to load.
+  // listener must point to an implementation of the OpHTTPListener interface
+  // that Opera will use to report results of the loading.
+  // If req_data->IsAsync() returns true this function will return immediately
+  // or else it will block until the URL is loaded.
+  virtual      void    RequestUrl(NPP plugin_instance,
+                               OpHTTPRequestDataProviderInterface *req_data,
+                                                          OpHTTPListener 
*listener) = 0;
+
+  // Request Opera to display a dialog.
+  // plugin_instance must contain the plugin object from the NPAPI invocation.
+  // It is used internally in Opera to identify the document context which the
+  // dialog should be opened in.
+  // html_file must point to a string identifying the html file to be used as
+  // a template for the dialog.
+  // width and height will be used to set the size of the dialog.
+  // arguments_string will contain a JSON formatted string with the arguments
+  // that will be passed to the dialog.
+  // After this call returns result will contain the JSON formatted results
+  // returned from the dialog.
+  virtual void OpenDialog(NPP plugin_instance,
+                                                  const unsigned short 
*html_file,
+                                                  int width, int height,
+                                                  const unsigned short 
*arguments_string,
+                                                  const unsigned short 
*&result) = 0;
+
+  // Create a Opera native WorkerPool object.
+  // Returns the NPAPI representation of the workerpool object.
+  // plugin_instance must contain the plugin object from the NPAPI invocation.
+  // It is used internally in Opera to identify the document context which the
+  // WorkerPool should be created in.
+  // factory specifies the NPAPI representation of the Gears factory object. 
+  virtual NPObject*
+         CreateWorkerPool(NPP plugin_instance, NPObject* factory) = 0;
+
+  // Sets the global object of the plugin_instance.
+  virtual      void
+         SetCurrentGlobalObject(NPP plugin_instance, NPObject* global_object) 
= 0;
+
+  // Request Opera to return the cookie value associated with the url url.
+  // After the function returns, cookie_out will point to the cookie data.
+  virtual void
+         GetCookieString(const unsigned short *url, const char *&cookie_out) = 
0;
+};
+
+#endif  // OPERA_CALLBACK_API_H__
==== 
//depot/googleclient/gears/opensource/third_party/opera/opera_local_server_interface.h#1
 - 
c:\MyDocs\Gears3/googleclient/gears/opensource/third_party/opera/opera_local_server_interface.h
 ====
# action=add type=text
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ 
googleclient/gears/opensource/third_party/opera/opera_local_server_interface.h  
    2008-11-27 18:12:33.000000000 +0000
@@ -0,0 +1,59 @@
+#ifndef OPERA_LOCAL_SERVER_INTERFACE_H__
+#define OPERA_LOCAL_SERVER_INTERFACE_H__
+
+// Interface used to read URL data from URLs stored in the Gears DB
+//
+// The cache reader is initialized by calling GetHeaderData() and then
+// all the other methods will return valid data.
+class OpCacheReaderInterface {
+ public:
+  // Called to fetch the list of headers for a specified URL.
+  // The name of the URL to fetch the headers of should be in url.
+  // After this function returns, header_str will point to an array of header
+  // lines.
+  // The number of entries in the header array will be returned in 
header_length
+  virtual bool GetHeaderData(const unsigned short *url, char **header_str,
+                                                  int &header_length) = 0;
+
+  // Called to indicate that the stored headers should be deleted.
+  virtual void ReleaseHeaderData() = 0;
+
+  // Called repeatedly to fetch the actual data the URL points to.
+  // After the call returns, the pre-allocated header_str buffer will be
+  // filled with the next chunk of data.
+  // The buffer will be filled with the first buffer_length chars of data, or 
less
+  // if there is less data remaining for the URL.
+  // The return value will indicate how many bytes were actually read. To get 
all
+  // the data, this function must be called until More() returns false.
+  virtual int GetBodyData(char *header_str, int buffer_length) = 0;
+
+  // Returns true if there is more stored data to fetch with GetBodyData().
+  virtual bool More() = 0;
+
+  // Called when we no longer need the Cache reader and it can be deleted.
+  virtual void Destroy() = 0;
+
+ protected:
+  virtual ~OpCacheReaderInterface() {}
+};
+
+// Interface for fetching URL data from the Gears DB
+//
+// If CanService() returns true, a cache reader can be created to get the data.
+class OpLocalServerInterface {
+ public:
+  // Returns true if the URL indicated by url can be served from
+  // the Gears database.
+  virtual bool CanService(const unsigned short *url) = 0;
+
+  // Returns a cache reader to read data from the DB.
+  virtual OpCacheReaderInterface *GetCacheReader() = 0;
+
+  // Called when the local server is not needed and can be deleted.
+  virtual void Destroy() = 0;
+
+ protected:
+  virtual ~OpLocalServerInterface() {}
+};
+
+#endif // OPERA_LOCAL_SERVER_INTERFACE_H__
==== 
//depot/googleclient/gears/opensource/third_party/opera/opera_worker_interface.h#1
 - 
c:\MyDocs\Gears3/googleclient/gears/opensource/third_party/opera/opera_worker_interface.h
 ====
# action=add type=text
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ googleclient/gears/opensource/third_party/opera/opera_worker_interface.h    
2008-11-27 18:12:35.000000000 +0000
@@ -0,0 +1,32 @@
+#ifndef OPERA_WORKER_INTERFACE_H__
+#define OPERA_WORKER_INTERFACE_H__
+
+#include "third_party/npapi/nphostapi.h"
+
+// Interface for the Opera native worker thread implementation to
+// communicate with the Gears plugin
+class OperaWorkerThreadInterface {
+ public:
+  virtual ~OperaWorkerThreadInterface(){}
+  // Will be called when Opera wants to get permanently delete
+  // the worker thread
+  virtual void Destroy() = 0;
+
+  // Called from Opera when we want to create a new worker thread.
+  // instance will be the plugin context from which the creation
+  // was triggered.
+  // global_object is the new global object created for the worker
+  // url is the URL which the worker will be created from
+  virtual NPObject* CreateWorkerFactory(NPP instance,
+                                                                               
NPObject* global_object,
+                                                                               
const unsigned short* url) = 0;
+
+  // Is called when Opera needs to suspend the creation of the
+  // worker thread for some reason
+  virtual void SuspendObjectCreation() = 0;
+
+  // Is called when Opera will resume the creation of the worker thread
+  virtual void ResumeObjectCreationAndUpdatePermissions() = 0;
+};
+
+#endif  // OPERA_WORKER_INTERFACE_H__

Reply via email to