Firefox 9 DevMode Plugin

Review at http://gwt-code-reviews.appspot.com/1620803

Review by: conroy@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10837 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/plugins/common/HostChannel.cpp b/plugins/common/HostChannel.cpp
index bff1b21..2cabb01 100644
--- a/plugins/common/HostChannel.cpp
+++ b/plugins/common/HostChannel.cpp
@@ -83,6 +83,7 @@
     disconnectFromHost();
     return false;
   }
+
   switch (type) {
     case MESSAGE_TYPE_PROTOCOL_VERSION:
     {
@@ -237,11 +238,10 @@
   char type;
   while (true) {
     flush();
-    Debug::log(Debug::Spam) << "Waiting for response, flushed output"
-        << Debug::flush;
+    Debug::log(Debug::Debugging) << "Waiting for response, flushed output" << Debug::flush;
     if (!readByte(type)) {
       if (isConnected()) {
-        Debug::log(Debug::Error) << "Failed to receive message type"
+        Debug::log(Debug::Debugging) << "Failed to receive message type"
             << Debug::flush;
       }
       return 0;
@@ -254,7 +254,7 @@
             Debug::log(Debug::Error) << "Failed to receive invoke message" << Debug::flush;
             return 0;
           }
-          Value returnValue;
+          gwt::Value returnValue;
           bool exception = handler->invoke(*this, imsg->getThis(), imsg->getMethodName(),
               imsg->getNumArgs(), imsg->getArgs(), &returnValue);
           handler->sendFreeValues(*this);
@@ -269,7 +269,7 @@
             Debug::log(Debug::Error) << "Failed to receive invoke special message" << Debug::flush;
             return 0;
           }
-          Value returnValue;
+          gwt::Value returnValue;
           bool exception = handler->invokeSpecial(*this, imsg->getDispatchId(),
               imsg->getNumArgs(), imsg->getArgs(), &returnValue);
           handler->sendFreeValues(*this);
@@ -319,81 +319,81 @@
   }
 }
 
-bool HostChannel::readValue(Value& valueRef) {
+bool HostChannel::readValue(gwt::Value& valueRef) {
   char typeBuf;
   if (!readByte(typeBuf)) return false;
-  Value::ValueType type = Value::ValueType(typeBuf);
+  gwt::Value::ValueType type = gwt::Value::ValueType(typeBuf);
   switch (type) {
-    case Value::NULL_TYPE:
+    case gwt::Value::NULL_TYPE:
       valueRef.setNull();
       return true;
-    case Value::UNDEFINED:
+    case gwt::Value::UNDEFINED:
       valueRef.setUndefined();
       return true;
-    case Value::BOOLEAN:
+    case gwt::Value::BOOLEAN:
       {
         char val;
         if (!readByte(val)) return false;
         valueRef.setBoolean(val != 0);
       }
       return true;
-    case Value::BYTE:
+    case gwt::Value::BYTE:
       {
         char val;
         if (!readByte(val)) return false;
         valueRef.setByte(val);
       }
       return true;
-    case Value::CHAR:
+    case gwt::Value::CHAR:
       {
         short val;
         if (!readShort(val)) return false;
         valueRef.setChar(val);
       }
       return true;
-    case Value::SHORT:
+    case gwt::Value::SHORT:
       {
         short val;
         if (!readShort(val)) return false;
         valueRef.setShort(val);
       }
       return true;
-    case Value::STRING:
+    case gwt::Value::STRING:
       {
         std::string val;
         if (!readString(val)) return false;
         valueRef.setString(val);
       }
       return true;
-    case Value::INT:
+    case gwt::Value::INT:
       {
         int val;
         if (!readInt(val)) return false;
         valueRef.setInt(val);
       }
       return true;
-    case Value::LONG:
+    case gwt::Value::LONG:
       {
         int64_t val;
         if (!readLong(val)) return false;
         valueRef.setLong(val);
       }
       return true;
-    case Value::DOUBLE:
+    case gwt::Value::DOUBLE:
       {
         double val;
         if (!readDouble(val)) return false;
         valueRef.setDouble(val);
       }
       return true;
-    case Value::JAVA_OBJECT:
+    case gwt::Value::JAVA_OBJECT:
       {
         int objId;
         if (!readInt(objId)) return false;
         valueRef.setJavaObject(objId);
       }
       return true;
-    case Value::JS_OBJECT:
+    case gwt::Value::JS_OBJECT:
       {
         int val;
         if (!readInt(val)) return false;
@@ -407,35 +407,35 @@
   return false;
 }
 
-bool HostChannel::sendValue(const Value& value) {
-  Value::ValueType type = value.getType();
+bool HostChannel::sendValue(const gwt::Value& value) {
+  gwt::Value::ValueType type = value.getType();
   if (!sendByte(type)) return false;
   switch (type) {
-    case Value::NULL_TYPE:
-    case Value::UNDEFINED:
+    case gwt::Value::NULL_TYPE:
+    case gwt::Value::UNDEFINED:
       // Null and Undefined only have the tag byte, no data
       return true;
-    case Value::BOOLEAN:
+    case gwt::Value::BOOLEAN:
       return sendByte(value.getBoolean() ? 1 : 0);
-    case Value::BYTE:
+    case gwt::Value::BYTE:
       return sendByte(value.getByte());
-    case Value::CHAR:
+    case gwt::Value::CHAR:
       return sendShort(short(value.getChar()));
-    case Value::SHORT:
+    case gwt::Value::SHORT:
       return sendShort(value.getShort());
-    case Value::INT:
+    case gwt::Value::INT:
       return sendInt(value.getInt());
-    case Value::LONG:
+    case gwt::Value::LONG:
       return sendLong(value.getLong());
-    case Value::STRING:
+    case gwt::Value::STRING:
       return sendString(value.getString());
-    case Value::DOUBLE:
+    case gwt::Value::DOUBLE:
       return sendDouble(value.getDouble());
-    case Value::FLOAT:
+    case gwt::Value::FLOAT:
       return sendFloat(value.getFloat());
-    case Value::JS_OBJECT:
+    case gwt::Value::JS_OBJECT:
       return sendInt(value.getJsObjectId());
-    case Value::JAVA_OBJECT:
+    case gwt::Value::JAVA_OBJECT:
       return sendInt(value.getJavaObjectId());
     default:
       Debug::log(Debug::Error) << "Unhandled value type sent to server: " << type << Debug::flush;
diff --git a/plugins/common/HostChannel.h b/plugins/common/HostChannel.h
index 3c5c5e3..e8a53ec 100644
--- a/plugins/common/HostChannel.h
+++ b/plugins/common/HostChannel.h
@@ -131,8 +131,8 @@
     return sendString(str.c_str(), static_cast<uint32_t>(str.length()));
   }
 
-  bool readValue(Value& valueRef);
-  bool sendValue(const Value& value);
+  bool readValue(gwt::Value& valueRef);
+  bool sendValue(const gwt::Value& value);
 
   ReturnMessage* reactToMessages(SessionHandler* handler, bool expectReturn);
 
diff --git a/plugins/common/InvokeMessage.cpp b/plugins/common/InvokeMessage.cpp
index 90fc790..9207f81 100644
--- a/plugins/common/InvokeMessage.cpp
+++ b/plugins/common/InvokeMessage.cpp
@@ -38,7 +38,7 @@
     printf("Failed to read method name\n");
     return 0;
   }
-  Value thisRef;
+  gwt::Value thisRef;
   if (!channel.readValue(thisRef)) {
     // TODO(jat): error handling
     printf("Failed to read thisRef\n");
@@ -50,7 +50,7 @@
     printf("Failed to read #args\n");
     return 0;
   }
-  scoped_array<Value> args(new Value[numArgs]);
+  scoped_array<gwt::Value> args(new gwt::Value[numArgs]);
   for (int i = 0; i < numArgs; ++i) {
     if (!channel.readValue(args[i])) {
       // TODO(jat): error handling
@@ -66,8 +66,8 @@
  * 
  * Note that the method to be invoked is sent as an integer (a dispatch id) to the server.
  */
-bool InvokeMessage::send(HostChannel& channel, const Value& thisRef, int methodDispatchId,
-    int numArgs, const Value* args) {
+bool InvokeMessage::send(HostChannel& channel, const gwt::Value& thisRef, int methodDispatchId,
+    int numArgs, const gwt::Value* args) {
   if (!channel.sendByte(TYPE)) return false;
   if (!channel.sendInt(methodDispatchId)) return false;
   if (!channel.sendValue(thisRef)) return false;
diff --git a/plugins/common/InvokeMessage.h b/plugins/common/InvokeMessage.h
index 7d57e30..0296d75 100644
--- a/plugins/common/InvokeMessage.h
+++ b/plugins/common/InvokeMessage.h
@@ -36,32 +36,32 @@
   static const char TYPE = MESSAGE_TYPE_INVOKE;
   static const int TOSTRING_DISP_ID = 0;
 private:
-  Value thisRef;
+  gwt::Value thisRef;
   std::string methodName;
   int methodDispatchId;
   int numArgs;
-  const Value* args;
+  const gwt::Value* args;
 
 protected:
   /**
    * @param args array of arguments -- InvokeMessage takes ownership and will
    *     destroy when it is destroyed.
    */
-  InvokeMessage(const Value& thisRef, const std::string& methodName,
-      int numArgs, const Value* args) : thisRef(thisRef), methodName(methodName),
+  InvokeMessage(const gwt::Value& thisRef, const std::string& methodName,
+      int numArgs, const gwt::Value* args) : thisRef(thisRef), methodName(methodName),
       numArgs(numArgs), args(args) {}
 
 public:
   ~InvokeMessage();
   virtual char getType() const;
 
-  Value getThis() const { return thisRef; }
+  gwt::Value getThis() const { return thisRef; }
   const std::string& getMethodName() const { return methodName; }
   int getNumArgs() const { return numArgs; }
-  const Value* const getArgs() const { return args; }
+  const gwt::Value* const getArgs() const { return args; }
 
   static InvokeMessage* receive(HostChannel& channel);
-  static bool send(HostChannel& channel, const Value& thisRef, int methodDispatchId,
-      int numArgs, const Value* args);
+  static bool send(HostChannel& channel, const gwt::Value& thisRef, int methodDispatchId,
+      int numArgs, const gwt::Value* args);
 };
 #endif
diff --git a/plugins/common/InvokeSpecialMessage.cpp b/plugins/common/InvokeSpecialMessage.cpp
index 5fd1540..0a9f418 100644
--- a/plugins/common/InvokeSpecialMessage.cpp
+++ b/plugins/common/InvokeSpecialMessage.cpp
@@ -45,7 +45,7 @@
     printf("Failed to read #args\n");
     return 0;
   }
-  scoped_array<Value> args(new Value[numArgs]);
+  scoped_array<gwt::Value> args(new gwt::Value[numArgs]);
   for (int i = 0; i < numArgs; ++i) {
     if (!channel.readValue(args[i])) {
       // TODO(jat): error handling
@@ -63,7 +63,7 @@
  * Request the server perform a special method and return the result.
  */
 bool InvokeSpecialMessage::send(HostChannel& channel, int dispatchId,
-    int numArgs, const Value* args) {
+    int numArgs, const gwt::Value* args) {
   if (!channel.sendByte(TYPE)) return false;
   if (!channel.sendByte(dispatchId)) return false;
   if (!channel.sendInt(numArgs)) return false;
diff --git a/plugins/common/InvokeSpecialMessage.h b/plugins/common/InvokeSpecialMessage.h
index 5888cc1..84c90ff 100644
--- a/plugins/common/InvokeSpecialMessage.h
+++ b/plugins/common/InvokeSpecialMessage.h
@@ -34,15 +34,15 @@
 private:
   SessionHandler::SpecialMethodId dispatchId;
   int numArgs;
-  const Value* args;
+  const gwt::Value* args;
 
 protected:
   /**
    * @param args array of arguments -- InvokeMessage takes ownership and will
    *     destroy when it is destroyed.
    */
-  InvokeSpecialMessage(SessionHandler::SpecialMethodId dispatchId, int numArgs, const Value* args) : dispatchId(dispatchId),
-      numArgs(numArgs), args(args) {}
+  InvokeSpecialMessage(SessionHandler::SpecialMethodId dispatchId, int numArgs,
+      const gwt::Value* args) : dispatchId(dispatchId), numArgs(numArgs), args(args) {}
 
 public:
   ~InvokeSpecialMessage();
@@ -50,10 +50,10 @@
 
   SessionHandler::SpecialMethodId getDispatchId() const { return dispatchId; }
   int getNumArgs() const { return numArgs; }
-  const Value* const getArgs() const { return args; }
+  const gwt::Value* const getArgs() const { return args; }
 
   static InvokeSpecialMessage* receive(HostChannel& channel);
   static bool send(HostChannel& channel, int dispatchId, int numArgs,
-      const Value* args);
+      const gwt::Value* args);
 };
 #endif
diff --git a/plugins/common/LoadModuleMessage.cpp b/plugins/common/LoadModuleMessage.cpp
index 1ee4ab3..525383b 100644
--- a/plugins/common/LoadModuleMessage.cpp
+++ b/plugins/common/LoadModuleMessage.cpp
@@ -30,7 +30,7 @@
     const std::string& tabKey, const std::string& sessionKey,
     const std::string& moduleName, const std::string& userAgent,
     SessionHandler* handler) {
-  Debug::log(Debug::Spam) << "LoadModule(url=\"" << url << "\", tabKey=\""
+  Debug::log(Debug::Debugging) << "LoadModule(url=\"" << url << "\", tabKey=\""
       << "\", sessionKey=\"" << sessionKey << "\", module=\"" << moduleName
       << "\")" << Debug::flush;
   if (!channel.sendByte(TYPE) || !channel.sendString(url)
@@ -45,6 +45,5 @@
   if (!ret.get()) {
     return false;
   }
-
   return !ret.get()->isException();
 }
diff --git a/plugins/common/ReturnMessage.cpp b/plugins/common/ReturnMessage.cpp
index 0149c1f..159d009 100644
--- a/plugins/common/ReturnMessage.cpp
+++ b/plugins/common/ReturnMessage.cpp
@@ -27,7 +27,7 @@
     // TODO(jat): error handling
     return 0;
   }
-  Value retval;
+  gwt::Value retval;
   if (!channel.readValue(retval)) {
     // TODO(jat): error handling
     return 0;
@@ -35,7 +35,7 @@
   return new ReturnMessage(isException != 0, retval);
 }
 
-bool ReturnMessage::send(HostChannel& channel, bool isException, const Value& retval) {
+bool ReturnMessage::send(HostChannel& channel, bool isException, const gwt::Value& retval) {
   if (!channel.sendByte(TYPE)) return false;
   if (!channel.sendByte(isException ? 1 : 0)) return false;
   return channel.sendValue(retval);
diff --git a/plugins/common/ReturnMessage.h b/plugins/common/ReturnMessage.h
index 374b9fe..29141ec 100644
--- a/plugins/common/ReturnMessage.h
+++ b/plugins/common/ReturnMessage.h
@@ -34,17 +34,17 @@
   static const char TYPE = MESSAGE_TYPE_RETURN;
 private:
   bool bisException;
-  Value retval;
+  gwt::Value retval;
 
 public:
-  ReturnMessage(bool isException, const Value& retValue) : bisException(isException),
+  ReturnMessage(bool isException, const gwt::Value& retValue) : bisException(isException),
       retval(retValue) {}
 
   bool isException() const { return bisException; }
-  const Value& getReturnValue() const { return retval; }
+  const gwt::Value& getReturnValue() const { return retval; }
   virtual char getType() const;
 
   static ReturnMessage* receive(HostChannel& channel);
-  static bool send(HostChannel& channel, bool isException, const Value& retValue);
+  static bool send(HostChannel& channel, bool isException, const gwt::Value& retValue);
 };
 #endif
diff --git a/plugins/common/ServerMethods.cpp b/plugins/common/ServerMethods.cpp
index 0be51b0..672b44a 100644
--- a/plugins/common/ServerMethods.cpp
+++ b/plugins/common/ServerMethods.cpp
@@ -27,26 +27,26 @@
 
 using std::string;
 
-Value ServerMethods::getProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
+gwt::Value ServerMethods::getProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
     int dispatchId) {
   if (!channel.isConnected()) {
     Debug::log(Debug::Debugging) << "Ignoring getProperty after disconnect"
         << Debug::flush;
-    return Value();
+    return gwt::Value();
   }
-  Value args[2];
+  gwt::Value args[2];
   args[0].setInt(objectRef);
   args[1].setInt(dispatchId);
   if (!InvokeSpecialMessage::send(channel, SPECIAL_GET_PROPERTY, 2, args)) {
     Debug::log(Debug::Error) << "  failed to send invoke of GetProperty(disp=" << dispatchId
         << ", obj=" << objectRef << ")" << Debug::flush;
-    return Value();
+    return gwt::Value();
   }
   scoped_ptr<ReturnMessage> retMsg(channel.reactToMessagesWhileWaitingForReturn(handler));
   if (!retMsg.get()) {
     Debug::log(Debug::Error) << "getProperty: get return value failed for GetProperty(disp="
         << dispatchId << ", obj=" << objectRef << ")" << Debug::flush;
-    return Value();
+    return gwt::Value();
   }
   return retMsg->getReturnValue();
 }
@@ -62,7 +62,7 @@
         << Debug::flush;
     return -2;
   }
-  Value arg;
+  gwt::Value arg;
   arg.setString(name);
   if (!InvokeSpecialMessage::send(channel, SPECIAL_HAS_METHOD, 1, &arg)) {
     Debug::log(Debug::Error) << "hasMethod: invoke(hasMethod) failed" << Debug::flush;
@@ -73,7 +73,7 @@
     Debug::log(Debug::Error) << "hasMethod: get return value failed" << Debug::flush;
     return -2;
   }
-  Value retval = retMsg->getReturnValue();
+  gwt::Value retval = retMsg->getReturnValue();
   // TODO(jat): better error handling?
   return retval.isInt() ? retval.getInt() : -2;
 }
@@ -89,7 +89,7 @@
         << Debug::flush;
     return -2;
   }
-  Value arg;
+  gwt::Value arg;
   arg.setString(name);
   if (!InvokeSpecialMessage::send(channel, SPECIAL_HAS_PROPERTY, 1, &arg)) {
     Debug::log(Debug::Error) << "hasProperty: invoke(hasProperty) failed" << Debug::flush;
@@ -100,20 +100,20 @@
     Debug::log(Debug::Error) << "hasProperty: get return value failed" << Debug::flush;
     return -2;
   }
-  Value retval = retMsg->getReturnValue();
+  gwt::Value retval = retMsg->getReturnValue();
   // TODO(jat): better error handling?
   return retval.isInt() ? retval.getInt() : -2;
 }
 
 bool ServerMethods::setProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
-    int dispatchId, const Value& value) {
+    int dispatchId, const gwt::Value& value) {
   if (!channel.isConnected()) {
     Debug::log(Debug::Debugging) << "Ignoring setProperty after disconnect"
         << Debug::flush;
     return false;
   }
   // TODO(jat): error handling?
-  Value args[3];
+  gwt::Value args[3];
   args[0].setInt(objectRef);
   args[1].setInt(dispatchId);
   args[2] = value;
diff --git a/plugins/common/ServerMethods.h b/plugins/common/ServerMethods.h
index 3ff0134..02bf921 100644
--- a/plugins/common/ServerMethods.h
+++ b/plugins/common/ServerMethods.h
@@ -33,7 +33,7 @@
    * @param dispatchID dispatch ID of field
    * @return the value of the property, undef if none (or on error)
    */
-  static Value getProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
+  static gwt::Value getProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
       int dispatchId);
   
   /**
@@ -63,7 +63,7 @@
    * @return false if an error occurred
    */
   static bool setProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
-      int dispatchId, const Value& value);
+      int dispatchId, const gwt::Value& value);
   
   /**
    * Tell the server that the client no longer has any references to the specified
diff --git a/plugins/common/SessionHandler.h b/plugins/common/SessionHandler.h
index aebd00d..159f762 100644
--- a/plugins/common/SessionHandler.h
+++ b/plugins/common/SessionHandler.h
@@ -84,8 +84,9 @@
    *
    * Returns true if an exception occurred.
    */
-  virtual bool invoke(HostChannel& channel, const Value& thisObj, const std::string& methodName,
-      int numArgs, const Value* const args, Value* returnValue)=0;
+  virtual bool invoke(HostChannel& channel, const gwt::Value& thisObj,
+      const std::string& methodName, int numArgs, const gwt::Value* const args,
+      gwt::Value* returnValue) = 0;
 
   /**
    * Invoke a plugin-provided method with the given args.  As above, this method does not own
@@ -94,7 +95,7 @@
    * Returns true if an exception occurred.
    */
   virtual bool invokeSpecial(HostChannel& channel, SpecialMethodId method, int numArgs,
-      const Value* const args, Value* returnValue) = 0;
+      const gwt::Value* const args, gwt::Value* returnValue) = 0;
 
   /**
    * Send any queued up free values back to the server.
diff --git a/plugins/common/Value.h b/plugins/common/Value.h
index d19b0b5..ab50f5e 100644
--- a/plugins/common/Value.h
+++ b/plugins/common/Value.h
@@ -27,6 +27,7 @@
 
 #include "BrowserChannel.h"
 
+namespace gwt {
 class Value {
 public:
   enum ValueType {
@@ -393,4 +394,6 @@
   return dbg;
 }
 
+} // namespace gwt
+
 #endif