Update browser plugins to support v2 wire protocol, and checkin some prebuilt
libraries for them. The XPI files are *not* checked in here until all
platforms are rebuilt with the changes -- otherwise, users would no longer
be able to use platforms that were left out. Log levels were changed in a
few places in the XPCOM plugin to reduce spaminess, especially in the event
the development mode server connection goes away while the page is still
running.
The Safari plugin changes have had only minimal changes, and the IE plugin
changes are completely untested. They are checked in anyway since they were
never brought up to common code changes made last year, and therefore can't
be built from trunk anyway, so they are certainly no worse off this way.
When Bob is in town next week, we will test the Safari plugin more thoroughly
(including building an install image) and get the IE plugin built/tested.
Patch by: jat
Review by: bobv
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5998 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/plugins/common/HostChannel.cpp b/plugins/common/HostChannel.cpp
index 896667e..53272da 100644
--- a/plugins/common/HostChannel.cpp
+++ b/plugins/common/HostChannel.cpp
@@ -37,6 +37,11 @@
#include "Platform.h"
#include "ByteOrder.h"
+#include "CheckVersionsMessage.h"
+#include "ProtocolVersionMessage.h"
+#include "ChooseTransportMessage.h"
+#include "SwitchTransportMessage.h"
+#include "FatalErrorMessage.h"
#include "FreeValueMessage.h"
#include "HostChannel.h"
#include "LoadJsniMessage.h"
@@ -65,6 +70,51 @@
return sock.connect(host, port);
}
+bool HostChannel::init(SessionHandler* handler, int minProtoVers,
+ int maxProtoVers, const std::string& hostedHtmlVers) {
+ Debug::log(Debug::Info) << "initializing connection: proto=" << minProtoVers
+ << "-" << maxProtoVers << ", hostedHtmlVersion=" << hostedHtmlVers
+ << Debug::flush;
+ // TODO(jat): support transport selection
+ CheckVersionsMessage::send(*this, minProtoVers, maxProtoVers, hostedHtmlVers);
+ flush();
+ char type;
+ if (!readByte(type)) {
+ handler->fatalError(*this, "Failed to receive message type");
+ Debug::log(Debug::Error) << "Failed to receive message type" << Debug::flush;
+ disconnectFromHost();
+ return false;
+ }
+ switch (type) {
+ case MESSAGE_TYPE_PROTOCOL_VERSION:
+ {
+ scoped_ptr<ProtocolVersionMessage> imsg(ProtocolVersionMessage
+ ::receive(*this));
+ if (!imsg.get()) {
+ Debug::log(Debug::Error) << "Failed to receive protocol version message"
+ << Debug::flush;
+ return false;
+ }
+ // TODO(jat): save selected protocol version when we support a range
+ break;
+ }
+ case MESSAGE_TYPE_FATAL_ERROR:
+ {
+ scoped_ptr<FatalErrorMessage> imsg(FatalErrorMessage::receive(*this));
+ if (!imsg.get()) {
+ Debug::log(Debug::Error) << "Failed to receive fatal error message"
+ << Debug::flush;
+ return false;
+ }
+ handler->fatalError(*this, imsg.get()->getError());
+ return false;
+ }
+ default:
+ return false;
+ }
+ return true;
+}
+
bool HostChannel::disconnectFromHost() {
Debug::log(Debug::Debugging) << "Disconnecting channel" << Debug::flush;
if (!isConnected()) {
@@ -189,9 +239,13 @@
char type;
while (true) {
flush();
- Debug::log(Debug::Spam) << "Waiting for response, flushed output" << Debug::flush;
+ Debug::log(Debug::Spam) << "Waiting for response, flushed output"
+ << Debug::flush;
if (!readByte(type)) {
- Debug::log(Debug::Error) << "Failed to receive message type" << Debug::flush;
+ if (isConnected()) {
+ Debug::log(Debug::Error) << "Failed to receive message type"
+ << Debug::flush;
+ }
return 0;
}
switch (type) {