summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-05 02:00:42 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-05 02:00:42 +0000
commitdb803aaecaa3270b2b21c3d4200dc04cf733b655 (patch)
treec88d90537845ef39c4d33c8b00deea1fc5844e60
parent83c8265e74ad2bca349e291e440ab9a8a0759093 (diff)
downloadchromium_src-db803aaecaa3270b2b21c3d4200dc04cf733b655.zip
chromium_src-db803aaecaa3270b2b21c3d4200dc04cf733b655.tar.gz
chromium_src-db803aaecaa3270b2b21c3d4200dc04cf733b655.tar.bz2
Move socket stream messages to content, in preparation for moving its dispatcher. In this change I also converted p2p_messages to use the new automated way of serializing structs.
Review URL: http://codereview.chromium.org/6621025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77019 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc1
-rw-r--r--chrome/browser/importer/importer_messages.h1
-rw-r--r--chrome/browser/ui/toolbar/toolbar_model.cc3
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/common/autofill_messages.cc1
-rw-r--r--chrome/common/automation_messages.cc2
-rw-r--r--chrome/common/chrome_constants.cc2
-rw-r--r--chrome/common/chrome_constants.h8
-rw-r--r--chrome/common/common_param_traits.cc20
-rw-r--r--chrome/common/common_param_traits.h11
-rw-r--r--chrome/common/common_param_traits_unittest.cc1
-rw-r--r--chrome/common/dom_storage_messages.cc2
-rw-r--r--chrome/common/plugin_messages.cc1
-rw-r--r--chrome/common/render_messages.h1
-rw-r--r--chrome/common/render_messages_internal.h60
-rw-r--r--chrome/common/socket_stream_dispatcher.cc36
-rw-r--r--chrome/common/utility_messages.h1
-rw-r--r--chrome/renderer/render_view.cc5
-rw-r--r--content/browser/renderer_host/socket_stream_dispatcher_host.cc42
-rw-r--r--content/browser/renderer_host/socket_stream_host.cc6
-rw-r--r--content/common/common_param_traits.cc30
-rw-r--r--content/common/common_param_traits.h40
-rw-r--r--content/common/content_constants.cc14
-rw-r--r--content/common/content_constants.h26
-rw-r--r--content/common/content_message_generator.cc32
-rw-r--r--content/common/content_message_generator.h8
-rw-r--r--content/common/p2p_messages.cc31
-rw-r--r--content/common/p2p_messages.h30
-rw-r--r--content/common/socket_stream.h (renamed from chrome/common/net/socket_stream.h)8
-rw-r--r--content/common/socket_stream_messages.h71
-rw-r--r--content/content_common.gypi19
-rw-r--r--ipc/ipc_message_utils.h1
32 files changed, 307 insertions, 209 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index ff3691f..82b62ae 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -79,6 +79,7 @@
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/common/common_param_traits.h"
#include "net/base/cookie_store.h"
#include "net/url_request/url_request_context.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
diff --git a/chrome/browser/importer/importer_messages.h b/chrome/browser/importer/importer_messages.h
index 19c88a9..46d6c98 100644
--- a/chrome/browser/importer/importer_messages.h
+++ b/chrome/browser/importer/importer_messages.h
@@ -15,6 +15,7 @@
#include "chrome/browser/importer/profile_writer.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/common/common_param_traits.h"
+#include "content/common/common_param_traits.h"
#include "ipc/ipc_message_utils.h"
namespace IPC {
diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc
index d2a468a..01bf34c 100644
--- a/chrome/browser/ui/toolbar/toolbar_model.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model.cc
@@ -18,6 +18,7 @@
#include "content/browser/tab_contents/navigation_controller.h"
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/common/content_constants.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "net/base/cert_status_flags.h"
@@ -48,7 +49,7 @@ std::wstring ToolbarModel::GetText() const {
url = entry->virtual_url();
}
}
- if (url.spec().length() > chrome::kMaxURLDisplayChars)
+ if (url.spec().length() > content::kMaxURLDisplayChars)
url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":");
// Note that we can't unescape spaces here, because if the user copies this
// and pastes it into another program, that program may think the URL ends at
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index a87b053..f711f828 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -49,6 +49,7 @@
'common/chrome_version_info.cc',
'common/chrome_version_info.h',
'common/common_message_generator.cc',
+ 'common/common_message_generator.h',
'common/common_param_traits.cc',
'common/common_param_traits.h',
'common/content_restriction.h',
@@ -508,7 +509,6 @@
'common/net/predictor_common.h',
'common/net/raw_host_resolver_proc.cc',
'common/net/raw_host_resolver_proc.h',
- 'common/net/socket_stream.h',
'common/net/url_fetcher.cc',
'common/net/url_fetcher.h',
'common/net/url_request_context_getter.cc',
diff --git a/chrome/common/autofill_messages.cc b/chrome/common/autofill_messages.cc
index 80b43f3..1243f1f 100644
--- a/chrome/common/autofill_messages.cc
+++ b/chrome/common/autofill_messages.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/common/common_param_traits.h"
+#include "content/common/common_param_traits.h"
#include "webkit/glue/form_data.h"
#include "webkit/glue/form_field.h"
#include "webkit/glue/password_form.h"
diff --git a/chrome/common/automation_messages.cc b/chrome/common/automation_messages.cc
index f5f1ccc..efa93a9 100644
--- a/chrome/common/automation_messages.cc
+++ b/chrome/common/automation_messages.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "content/common/common_param_traits.h"
+
#define IPC_MESSAGE_IMPL
#include "chrome/common/automation_messages.h"
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index 0cb0fca..43c36a4 100644
--- a/chrome/common/chrome_constants.cc
+++ b/chrome/common/chrome_constants.cc
@@ -118,8 +118,6 @@ const int kStatsMaxThreads = 32;
const int kStatsMaxCounters = 3000;
const size_t kMaxTitleChars = 4 * 1024;
-const size_t kMaxURLChars = 2 * 1024 * 1024;
-const size_t kMaxURLDisplayChars = 32 * 1024;
// We don't enable record mode in the released product because users could
// potentially be tricked into running a product in record mode without
diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h
index 56be2f8..c94ac25 100644
--- a/chrome/common/chrome_constants.h
+++ b/chrome/common/chrome_constants.h
@@ -78,14 +78,6 @@ extern const int kStatsMaxCounters;
// The maximum number of characters of the document's title that we're willing
// to accept in the browser process.
extern const size_t kMaxTitleChars;
-// The maximum number of characters in the URL that we're willing to accept
-// in the browser process. It is set low enough to avoid damage to the browser
-// but high enough that a web site can abuse location.hash for a little storage.
-// We have different values for "max accepted" and "max displayed" because
-// a data: URI may be legitimately massive, but the full URI would kill all
-// known operating systems if you dropped it into a UI control.
-extern const size_t kMaxURLChars;
-extern const size_t kMaxURLDisplayChars;
extern const bool kRecordModeEnabled;
diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc
index 8189922..94c97c9 100644
--- a/chrome/common/common_param_traits.cc
+++ b/chrome/common/common_param_traits.cc
@@ -10,6 +10,7 @@
#include "chrome/common/geoposition.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/web_apps.h"
+#include "content/common/common_param_traits.h"
#include "googleurl/src/gurl.h"
#include "net/base/host_port_pair.h"
#include "net/base/upload_data.h"
@@ -104,25 +105,6 @@ void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::string* l) {
#endif // EXCLUDE_SKIA_DEPENDENCIES
-void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
- m->WriteString(p.possibly_invalid_spec());
- // TODO(brettw) bug 684583: Add encoding for query params.
-}
-
-bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) {
- std::string s;
- if (!m->ReadString(iter, &s) || s.length() > chrome::kMaxURLChars) {
- *p = GURL();
- return false;
- }
- *p = GURL(s);
- return true;
-}
-
-void ParamTraits<GURL>::Log(const GURL& p, std::string* l) {
- l->append(p.spec());
-}
-
void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) {
m->WriteInt(p.x());
m->WriteInt(p.y());
diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h
index 860dcc6..abeaa117 100644
--- a/chrome/common/common_param_traits.h
+++ b/chrome/common/common_param_traits.h
@@ -35,7 +35,6 @@
// Forward declarations.
struct Geoposition;
-class GURL;
class SkBitmap;
class DictionaryValue;
class ListValue;
@@ -78,16 +77,6 @@ struct ParamTraits<SkBitmap> {
static void Log(const param_type& p, std::string* l);
};
-
-template <>
-struct ParamTraits<GURL> {
- typedef GURL param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, void** iter, param_type* p);
- static void Log(const param_type& p, std::string* l);
-};
-
-
template <>
struct ParamTraits<gfx::Point> {
typedef gfx::Point param_type;
diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc
index 1dd62f6..186e68e 100644
--- a/chrome/common/common_param_traits_unittest.cc
+++ b/chrome/common/common_param_traits_unittest.cc
@@ -9,6 +9,7 @@
#include "base/values.h"
#include "chrome/common/common_param_traits.h"
#include "chrome/common/geoposition.h"
+#include "content/common/common_param_traits.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_utils.h"
diff --git a/chrome/common/dom_storage_messages.cc b/chrome/common/dom_storage_messages.cc
index 9aee345..3ee1f8d 100644
--- a/chrome/common/dom_storage_messages.cc
+++ b/chrome/common/dom_storage_messages.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/common_param_traits.h"
+#include "content/common/common_param_traits.h"
#define IPC_MESSAGE_IMPL
#include "chrome/common/dom_storage_messages.h"
diff --git a/chrome/common/plugin_messages.cc b/chrome/common/plugin_messages.cc
index 26d2aec..fe09d04 100644
--- a/chrome/common/plugin_messages.cc
+++ b/chrome/common/plugin_messages.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/utf_string_conversions.h"
+#include "content/common/common_param_traits.h"
#include "ipc/ipc_channel_handle.h"
#define IPC_MESSAGE_IMPL
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index a102bd7..fa07f83 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -20,6 +20,7 @@
#include "chrome/common/translate_errors.h"
#include "chrome/common/view_types.h"
#include "chrome/common/webkit_param_traits.h"
+#include "content/common/common_param_traits.h"
#include "ipc/ipc_message_utils.h"
#include "ipc/ipc_platform_file.h" // ifdefed typedef.
#include "ui/base/clipboard/clipboard.h" // enum
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index ba6aa0b..2aabd92 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -917,33 +917,6 @@ IPC_MESSAGE_CONTROL1(ViewMsg_SetIPCLoggingEnabled,
bool /* on or off */)
#endif
-// Socket Stream messages:
-// These are messages from the browser to the SocketStreamHandle on
-// a renderer.
-
-// A |socket_id| is assigned by ViewHostMsg_SocketStream_Connect.
-// The Socket Stream is connected. The SocketStreamHandle should keep track
-// of how much it has pending (how much it has requested to be sent) and
-// shouldn't go over |max_pending_send_allowed| bytes.
-IPC_MESSAGE_CONTROL2(ViewMsg_SocketStream_Connected,
- int /* socket_id */,
- int /* max_pending_send_allowed */)
-
-// |data| is received on the Socket Stream.
-IPC_MESSAGE_CONTROL2(ViewMsg_SocketStream_ReceivedData,
- int /* socket_id */,
- std::vector<char> /* data */)
-
-// |amount_sent| bytes of data requested by
-// ViewHostMsg_SocketStream_SendData has been sent on the Socket Stream.
-IPC_MESSAGE_CONTROL2(ViewMsg_SocketStream_SentData,
- int /* socket_id */,
- int /* amount_sent */)
-
-// The Socket Stream is closed.
-IPC_MESSAGE_CONTROL1(ViewMsg_SocketStream_Closed,
- int /* socket_id */)
-
// SpellChecker messages.
// Passes some initialization params to the renderer's spellchecker. This can
@@ -2307,39 +2280,6 @@ IPC_MESSAGE_ROUTED4(ViewHostMsg_PageTranslated,
TranslateErrors::Type /* the error type if available */)
//---------------------------------------------------------------------------
-// Socket Stream messages:
-// These are messages from the SocketStreamHandle to the browser.
-
-// Open new Socket Stream for the |socket_url| identified by |socket_id|
-// in the renderer process.
-// The browser starts connecting asynchronously.
-// Once Socket Stream connection is established, the browser will send
-// ViewMsg_SocketStream_Connected back.
-IPC_MESSAGE_CONTROL2(ViewHostMsg_SocketStream_Connect,
- GURL /* socket_url */,
- int /* socket_id */)
-
-// Request to send data on the Socket Stream.
-// SocketStreamHandle can send data at most |max_pending_send_allowed| bytes,
-// which is given by ViewMsg_SocketStream_Connected at any time.
-// The number of pending bytes can be tracked by size of |data| sent
-// and |amount_sent| parameter of ViewMsg_SocketStream_DataSent.
-// That is, the following constraints is applied:
-// (accumulated total of |data|) - (accumulated total of |amount_sent|)
-// <= |max_pending_send_allowed|
-// If the SocketStreamHandle ever tries to exceed the
-// |max_pending_send_allowed|, the connection will be closed.
-IPC_MESSAGE_CONTROL2(ViewHostMsg_SocketStream_SendData,
- int /* socket_id */,
- std::vector<char> /* data */)
-
-// Request to close the Socket Stream.
-// The browser will send ViewMsg_SocketStream_Closed back when the Socket
-// Stream is completely closed.
-IPC_MESSAGE_CONTROL1(ViewHostMsg_SocketStream_Close,
- int /* socket_id */)
-
-//---------------------------------------------------------------------------
// Request for cryptographic operation messages:
// These are messages from the renderer to the browser to perform a
// cryptographic operation.
diff --git a/chrome/common/socket_stream_dispatcher.cc b/chrome/common/socket_stream_dispatcher.cc
index a7e484a..362c19b 100644
--- a/chrome/common/socket_stream_dispatcher.cc
+++ b/chrome/common/socket_stream_dispatcher.cc
@@ -11,10 +11,9 @@
#include "base/ref_counted.h"
#include "base/task.h"
#include "chrome/common/child_thread.h"
-#include "chrome/common/render_messages.h"
-#include "chrome/common/net/socket_stream.h"
+#include "content/common/socket_stream.h"
+#include "content/common/socket_stream_messages.h"
#include "googleurl/src/gurl.h"
-#include "ipc/ipc_message.h"
#include "webkit/glue/websocketstreamhandle_bridge.h"
#include "webkit/glue/websocketstreamhandle_delegate.h"
@@ -27,7 +26,7 @@ class IPCWebSocketStreamHandleBridge
ChildThread* child_thread,
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate)
- : socket_id_(chrome_common_net::kNoSocketId),
+ : socket_id_(content_common::kNoSocketId),
child_thread_(child_thread),
handle_(handle),
delegate_(delegate) {}
@@ -71,9 +70,9 @@ IPCWebSocketStreamHandleBridge* IPCWebSocketStreamHandleBridge::FromSocketId(
IPCWebSocketStreamHandleBridge::~IPCWebSocketStreamHandleBridge() {
DVLOG(1) << "IPCWebSocketStreamHandleBridge destructor socket_id="
<< socket_id_;
- if (socket_id_ != chrome_common_net::kNoSocketId) {
- child_thread_->Send(new ViewHostMsg_Close(socket_id_));
- socket_id_ = chrome_common_net::kNoSocketId;
+ if (socket_id_ != content_common::kNoSocketId) {
+ child_thread_->Send(new SocketStreamHostMsg_Close(socket_id_));
+ socket_id_ = content_common::kNoSocketId;
}
}
@@ -90,7 +89,7 @@ bool IPCWebSocketStreamHandleBridge::Send(
const std::vector<char>& data) {
DVLOG(1) << "Send data.size=" << data.size();
if (child_thread_->Send(
- new ViewHostMsg_SocketStream_SendData(socket_id_, data))) {
+ new SocketStreamHostMsg_SendData(socket_id_, data))) {
if (delegate_)
delegate_->WillSendData(handle_, &data[0], data.size());
return true;
@@ -100,7 +99,7 @@ bool IPCWebSocketStreamHandleBridge::Send(
void IPCWebSocketStreamHandleBridge::Close() {
DVLOG(1) << "Close socket_id" << socket_id_;
- child_thread_->Send(new ViewHostMsg_SocketStream_Close(socket_id_));
+ child_thread_->Send(new SocketStreamHostMsg_Close(socket_id_));
}
void IPCWebSocketStreamHandleBridge::OnConnected(int max_pending_send_allowed) {
@@ -123,9 +122,9 @@ void IPCWebSocketStreamHandleBridge::OnReceivedData(
void IPCWebSocketStreamHandleBridge::OnClosed() {
DVLOG(1) << "IPCWebSocketStreamHandleBridge::OnClosed";
- if (socket_id_ != chrome_common_net::kNoSocketId) {
+ if (socket_id_ != content_common::kNoSocketId) {
all_bridges.Remove(socket_id_);
- socket_id_ = chrome_common_net::kNoSocketId;
+ socket_id_ = content_common::kNoSocketId;
}
if (delegate_)
delegate_->DidClose(handle_);
@@ -135,15 +134,14 @@ void IPCWebSocketStreamHandleBridge::OnClosed() {
void IPCWebSocketStreamHandleBridge::DoConnect(const GURL& url) {
DCHECK(child_thread_);
- DCHECK_EQ(socket_id_, chrome_common_net::kNoSocketId);
+ DCHECK_EQ(socket_id_, content_common::kNoSocketId);
if (delegate_)
delegate_->WillOpenStream(handle_, url);
socket_id_ = all_bridges.Add(this);
- DCHECK_NE(socket_id_, chrome_common_net::kNoSocketId);
+ DCHECK_NE(socket_id_, content_common::kNoSocketId);
AddRef(); // Released in OnClosed().
- if (child_thread_->Send(
- new ViewHostMsg_SocketStream_Connect(url, socket_id_))) {
+ if (child_thread_->Send(new SocketStreamHostMsg_Connect(url, socket_id_))) {
DVLOG(1) << "Connect socket_id=" << socket_id_;
// TODO(ukai): timeout to OnConnected.
} else {
@@ -167,10 +165,10 @@ SocketStreamDispatcher::CreateBridge(
bool SocketStreamDispatcher::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(SocketStreamDispatcher, msg)
- IPC_MESSAGE_HANDLER(ViewMsg_SocketStream_Connected, OnConnected)
- IPC_MESSAGE_HANDLER(ViewMsg_SocketStream_SentData, OnSentData)
- IPC_MESSAGE_HANDLER(ViewMsg_SocketStream_ReceivedData, OnReceivedData)
- IPC_MESSAGE_HANDLER(ViewMsg_SocketStream_Closed, OnClosed)
+ IPC_MESSAGE_HANDLER(SocketStreamMsg_Connected, OnConnected)
+ IPC_MESSAGE_HANDLER(SocketStreamMsg_SentData, OnSentData)
+ IPC_MESSAGE_HANDLER(SocketStreamMsg_ReceivedData, OnReceivedData)
+ IPC_MESSAGE_HANDLER(SocketStreamMsg_Closed, OnClosed)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
diff --git a/chrome/common/utility_messages.h b/chrome/common/utility_messages.h
index 7d00790..c6382ce 100644
--- a/chrome/common/utility_messages.h
+++ b/chrome/common/utility_messages.h
@@ -16,6 +16,7 @@
#include "chrome/common/indexed_db_key.h"
#include "chrome/common/indexed_db_param_traits.h"
#include "chrome/common/serialized_script_value.h"
+#include "content/common/common_param_traits.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_utils.h"
#include "printing/backend/print_backend.h"
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index d73032e..ac2d0eb 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -104,6 +104,7 @@
#include "chrome/renderer/webplugin_delegate_proxy.h"
#include "chrome/renderer/websharedworker_proxy.h"
#include "chrome/renderer/webworker_proxy.h"
+#include "content/common/content_constants.h"
#include "grit/generated_resources.h"
#include "grit/renderer_resources.h"
#include "media/base/filter_collection.h"
@@ -2453,12 +2454,12 @@ void RenderView::showContextMenu(
if (spelled_right)
params.misspelled_word.clear();
}
- // Serializing a GURL longer than chrome::kMaxURLChars will fail, so don't do
+ // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do
// it. We replace it with an empty GURL so the appropriate items are disabled
// in the context menu.
// TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large
// data encoded images. We should have a way to save them.
- if (params.src_url.spec().size() > chrome::kMaxURLChars)
+ if (params.src_url.spec().size() > content::kMaxURLChars)
params.src_url = GURL();
context_menu_node_ = data.node;
Send(new ViewHostMsg_ContextMenu(routing_id_, params));
diff --git a/content/browser/renderer_host/socket_stream_dispatcher_host.cc b/content/browser/renderer_host/socket_stream_dispatcher_host.cc
index 4b88ff0..d3c1b3a 100644
--- a/content/browser/renderer_host/socket_stream_dispatcher_host.cc
+++ b/content/browser/renderer_host/socket_stream_dispatcher_host.cc
@@ -6,11 +6,11 @@
#include "base/logging.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/render_messages.h"
-#include "chrome/common/render_messages_params.h"
-#include "chrome/common/net/socket_stream.h"
#include "chrome/common/net/url_request_context_getter.h"
+#include "chrome/common/render_messages_params.h"
#include "content/browser/renderer_host/socket_stream_host.h"
+#include "content/common/socket_stream.h"
+#include "content/common/socket_stream_messages.h"
#include "net/websockets/websocket_job.h"
#include "net/websockets/websocket_throttle.h"
@@ -34,9 +34,9 @@ bool SocketStreamDispatcherHost::OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(SocketStreamDispatcherHost, message, *message_was_ok)
- IPC_MESSAGE_HANDLER(ViewHostMsg_SocketStream_Connect, OnConnect)
- IPC_MESSAGE_HANDLER(ViewHostMsg_SocketStream_SendData, OnSendData)
- IPC_MESSAGE_HANDLER(ViewHostMsg_SocketStream_Close, OnCloseReq)
+ IPC_MESSAGE_HANDLER(SocketStreamHostMsg_Connect, OnConnect)
+ IPC_MESSAGE_HANDLER(SocketStreamHostMsg_SendData, OnSendData)
+ IPC_MESSAGE_HANDLER(SocketStreamHostMsg_Close, OnCloseReq)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
return handled;
@@ -48,13 +48,13 @@ void SocketStreamDispatcherHost::OnConnected(net::SocketStream* socket,
int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket);
DVLOG(1) << "SocketStreamDispatcherHost::OnConnected socket_id=" << socket_id
<< " max_pending_send_allowed=" << max_pending_send_allowed;
- if (socket_id == chrome_common_net::kNoSocketId) {
+ if (socket_id == content_common::kNoSocketId) {
LOG(ERROR) << "NoSocketId in OnConnected";
return;
}
- if (!Send(new ViewMsg_SocketStream_Connected(
+ if (!Send(new SocketStreamMsg_Connected(
socket_id, max_pending_send_allowed))) {
- LOG(ERROR) << "ViewMsg_SocketStream_Connected failed.";
+ LOG(ERROR) << "SocketStreamMsg_Connected failed.";
DeleteSocketStreamHost(socket_id);
}
}
@@ -64,12 +64,12 @@ void SocketStreamDispatcherHost::OnSentData(net::SocketStream* socket,
int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket);
DVLOG(1) << "SocketStreamDispatcherHost::OnSentData socket_id=" << socket_id
<< " amount_sent=" << amount_sent;
- if (socket_id == chrome_common_net::kNoSocketId) {
+ if (socket_id == content_common::kNoSocketId) {
LOG(ERROR) << "NoSocketId in OnReceivedData";
return;
}
- if (!Send(new ViewMsg_SocketStream_SentData(socket_id, amount_sent))) {
- LOG(ERROR) << "ViewMsg_SocketStream_SentData failed.";
+ if (!Send(new SocketStreamMsg_SentData(socket_id, amount_sent))) {
+ LOG(ERROR) << "SocketStreamMsg_SentData failed.";
DeleteSocketStreamHost(socket_id);
}
}
@@ -79,13 +79,13 @@ void SocketStreamDispatcherHost::OnReceivedData(
int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket);
DVLOG(1) << "SocketStreamDispatcherHost::OnReceiveData socket_id="
<< socket_id;
- if (socket_id == chrome_common_net::kNoSocketId) {
+ if (socket_id == content_common::kNoSocketId) {
LOG(ERROR) << "NoSocketId in OnReceivedData";
return;
}
- if (!Send(new ViewMsg_SocketStream_ReceivedData(
+ if (!Send(new SocketStreamMsg_ReceivedData(
socket_id, std::vector<char>(data, data + len)))) {
- LOG(ERROR) << "ViewMsg_SocketStream_ReceivedData failed.";
+ LOG(ERROR) << "SocketStreamMsg_ReceivedData failed.";
DeleteSocketStreamHost(socket_id);
}
}
@@ -93,7 +93,7 @@ void SocketStreamDispatcherHost::OnReceivedData(
void SocketStreamDispatcherHost::OnClose(net::SocketStream* socket) {
int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket);
DVLOG(1) << "SocketStreamDispatcherHost::OnClosed socket_id=" << socket_id;
- if (socket_id == chrome_common_net::kNoSocketId) {
+ if (socket_id == content_common::kNoSocketId) {
LOG(ERROR) << "NoSocketId in OnClose";
return;
}
@@ -104,7 +104,7 @@ void SocketStreamDispatcherHost::OnClose(net::SocketStream* socket) {
void SocketStreamDispatcherHost::OnConnect(const GURL& url, int socket_id) {
DVLOG(1) << "SocketStreamDispatcherHost::OnConnect url=" << url
<< " socket_id=" << socket_id;
- DCHECK_NE(chrome_common_net::kNoSocketId, socket_id);
+ DCHECK_NE(content_common::kNoSocketId, socket_id);
if (hosts_.Lookup(socket_id)) {
LOG(ERROR) << "socket_id=" << socket_id << " already registered.";
return;
@@ -142,14 +142,18 @@ void SocketStreamDispatcherHost::DeleteSocketStreamHost(int socket_id) {
DCHECK(socket_stream_host);
delete socket_stream_host;
hosts_.Remove(socket_id);
- if (!Send(new ViewMsg_SocketStream_Closed(socket_id))) {
- LOG(ERROR) << "ViewMsg_SocketStream_Closed failed.";
+ if (!Send(new SocketStreamMsg_Closed(socket_id))) {
+ LOG(ERROR) << "SocketStreamMsg_Closed failed.";
}
}
net::URLRequestContext* SocketStreamDispatcherHost::GetURLRequestContext() {
net::URLRequestContext* rv = NULL;
if (url_request_context_override_.get()) {
+ // TODO(jam): temporary code until Gears is taken out, then
+ // GetRequestContext will take a different parameter and we can take out
+ // this struct and the #include "chrome/common/render_messages_params.h"
+ // above.
ViewHostMsg_Resource_Request request;
rv = url_request_context_override_->GetRequestContext(request);
}
diff --git a/content/browser/renderer_host/socket_stream_host.cc b/content/browser/renderer_host/socket_stream_host.cc
index e98f7db..c2f1a79 100644
--- a/content/browser/renderer_host/socket_stream_host.cc
+++ b/content/browser/renderer_host/socket_stream_host.cc
@@ -5,7 +5,7 @@
#include "content/browser/renderer_host/socket_stream_host.h"
#include "base/logging.h"
-#include "chrome/common/net/socket_stream.h"
+#include "content/common/socket_stream.h"
#include "net/socket_stream/socket_stream_job.h"
static const char* kSocketIdKey = "socketId";
@@ -25,7 +25,7 @@ SocketStreamHost::SocketStreamHost(
int socket_id)
: delegate_(delegate),
socket_id_(socket_id) {
- DCHECK_NE(socket_id_, chrome_common_net::kNoSocketId);
+ DCHECK_NE(socket_id_, content_common::kNoSocketId);
VLOG(1) << "SocketStreamHost: socket_id=" << socket_id_;
}
@@ -36,7 +36,7 @@ int SocketStreamHost::SocketIdFromSocketStream(net::SocketStream* socket) {
SocketStreamId* socket_stream_id = static_cast<SocketStreamId*>(d);
return socket_stream_id->socket_id();
}
- return chrome_common_net::kNoSocketId;
+ return content_common::kNoSocketId;
}
SocketStreamHost::~SocketStreamHost() {
diff --git a/content/common/common_param_traits.cc b/content/common/common_param_traits.cc
new file mode 100644
index 0000000..d25cb5b
--- /dev/null
+++ b/content/common/common_param_traits.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/common_param_traits.h"
+
+#include "content/common/content_constants.h"
+
+namespace IPC {
+
+void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
+ m->WriteString(p.possibly_invalid_spec());
+ // TODO(brettw) bug 684583: Add encoding for query params.
+}
+
+bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) {
+ std::string s;
+ if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) {
+ *p = GURL();
+ return false;
+ }
+ *p = GURL(s);
+ return true;
+}
+
+void ParamTraits<GURL>::Log(const GURL& p, std::string* l) {
+ l->append(p.spec());
+}
+
+} // namespace IPC
diff --git a/content/common/common_param_traits.h b/content/common/common_param_traits.h
new file mode 100644
index 0000000..9717dcc
--- /dev/null
+++ b/content/common/common_param_traits.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is used to define IPC::ParamTraits<> specializations for a number
+// of types so that they can be serialized over IPC. IPC::ParamTraits<>
+// specializations for basic types (like int and std::string) and types in the
+// 'base' project can be found in ipc/ipc_message_utils.h. This file contains
+// specializations for types that are used by the content code, and which need
+// manual serialization code. This is usually because they're not structs with
+// public members..
+
+#ifndef CONTENT_COMMON_COMMON_PARAM_TRAITS_H_
+#define CONTENT_COMMON_COMMON_PARAM_TRAITS_H_
+#pragma once
+
+#include "googleurl/src/gurl.h"
+#include "ipc/ipc_message_utils.h"
+// !!! WARNING: DO NOT ADD NEW WEBKIT DEPENDENCIES !!!
+//
+// That means don't add #includes to any file in 'webkit/' or
+// 'third_party/WebKit/'. Chrome Frame and NACL build parts of base/ and
+// content/common/ for a mini-library that doesn't depend on webkit.
+
+// Forward declarations.
+class GURL;
+
+namespace IPC {
+
+template <>
+struct ParamTraits<GURL> {
+ typedef GURL param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
+} // namespace IPC
+
+#endif // CONTENT_COMMON_COMMON_PARAM_TRAITS_H_
diff --git a/content/common/content_constants.cc b/content/common/content_constants.cc
new file mode 100644
index 0000000..2532fc1
--- /dev/null
+++ b/content/common/content_constants.cc
@@ -0,0 +1,14 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/content_constants.h"
+
+namespace content {
+
+const size_t kMaxURLChars = 2 * 1024 * 1024;
+const size_t kMaxURLDisplayChars = 32 * 1024;
+
+} // namespace content
+
+#undef FPL
diff --git a/content/common/content_constants.h b/content/common/content_constants.h
new file mode 100644
index 0000000..ca94329
--- /dev/null
+++ b/content/common/content_constants.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// A handful of resource-like constants related to the Content application.
+
+#ifndef CONTENT_COMMON_CHROME_CONSTANTS_H_
+#define CONTENT_COMMON_CHROME_CONSTANTS_H_
+#pragma once
+
+#include <stddef.h> // For size_t
+
+namespace content {
+
+// The maximum number of characters in the URL that we're willing to accept
+// in the browser process. It is set low enough to avoid damage to the browser
+// but high enough that a web site can abuse location.hash for a little storage.
+// We have different values for "max accepted" and "max displayed" because
+// a data: URI may be legitimately massive, but the full URI would kill all
+// known operating systems if you dropped it into a UI control.
+extern const size_t kMaxURLChars;
+extern const size_t kMaxURLDisplayChars;
+
+} // namespace content
+
+#endif // CONTENT_COMMON_CHROME_CONSTANTS_H_
diff --git a/content/common/content_message_generator.cc b/content/common/content_message_generator.cc
new file mode 100644
index 0000000..eacddef
--- /dev/null
+++ b/content/common/content_message_generator.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Get basic type definitions.
+#define IPC_MESSAGE_IMPL
+#include "content/common/common_param_traits.h"
+#include "content/common/content_message_generator.h"
+
+// Generate constructors.
+#include "ipc/struct_constructor_macros.h"
+#include "content/common/content_message_generator.h"
+
+// Generate destructors.
+#include "ipc/struct_destructor_macros.h"
+#include "content/common/content_message_generator.h"
+
+namespace IPC {
+
+// Generate param traits write methods.
+#include "ipc/param_traits_write_macros.h"
+#include "content/common/content_message_generator.h"
+
+// Generate param traits read methods.
+#include "ipc/param_traits_read_macros.h"
+#include "content/common/content_message_generator.h"
+
+// Generate param traits log methods.
+#include "ipc/param_traits_log_macros.h"
+#include "content/common/content_message_generator.h"
+
+} // namespace IPC
diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h
new file mode 100644
index 0000000..bcda993
--- /dev/null
+++ b/content/common/content_message_generator.h
@@ -0,0 +1,8 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Multiply-included file, hence no include guard.
+
+#include "content/common/p2p_messages.h"
+#include "content/common/socket_stream_messages.h"
diff --git a/content/common/p2p_messages.cc b/content/common/p2p_messages.cc
deleted file mode 100644
index 82c5983..0000000
--- a/content/common/p2p_messages.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#define IPC_MESSAGE_IMPL
-#include "content/common/p2p_messages.h"
-
-namespace IPC {
-
-void ParamTraits<P2PSocketAddress>::Write(Message* m, const param_type& p) {
- WriteParam(m, p.address);
- WriteParam(m, p.port);
-}
-
-bool ParamTraits<P2PSocketAddress>::Read(const Message* m,
- void** iter,
- param_type* p) {
- return
- ReadParam(m, iter, &p->address) &&
- ReadParam(m, iter, &p->port);
-}
-
-void ParamTraits<P2PSocketAddress>::Log(const param_type& p, std::string* l) {
- l->append("(");
- LogParam(p.address, l);
- l->append(", ");
- LogParam(p.port, l);
- l->append(")");
-}
-
-} // namespace IPC
diff --git a/content/common/p2p_messages.h b/content/common/p2p_messages.h
index 6ab75df..8424fe1 100644
--- a/content/common/p2p_messages.h
+++ b/content/common/p2p_messages.h
@@ -3,15 +3,20 @@
// found in the LICENSE file.
// IPC messages for the P2P Transport API.
-
-#ifndef CONTENT_COMMON_P2P_MESSAGES_H_
-#define CONTENT_COMMON_P2P_MESSAGES_H_
+// Multiply-included message file, hence no include guard.
#include "content/common/p2p_sockets.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START P2PMsgStart
+IPC_STRUCT_TRAITS_BEGIN(P2PSocketAddress)
+ IPC_STRUCT_TRAITS_MEMBER(address)
+ IPC_STRUCT_TRAITS_MEMBER(port)
+IPC_STRUCT_TRAITS_END()
+
+IPC_ENUM_TRAITS(P2PSocketType)
+
// P2P Socket messages sent from the browser to the renderer.
IPC_MESSAGE_ROUTED2(P2PMsg_OnSocketCreated,
@@ -41,22 +46,3 @@ IPC_MESSAGE_ROUTED3(P2PHostMsg_Send,
IPC_MESSAGE_ROUTED1(P2PHostMsg_DestroySocket,
int /* socket_id */)
-
-namespace IPC {
-
-template <>
-struct ParamTraits<P2PSocketAddress> {
- typedef P2PSocketAddress param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, void** iter, param_type* p);
- static void Log(const param_type& p, std::string* l);
-};
-
-template <>
-struct SimilarTypeTraits<P2PSocketType> {
- typedef int Type;
-};
-
-} // namespace IPC
-
-#endif // CONTENT_COMMON_P2P_MESSAGES_H_
diff --git a/chrome/common/net/socket_stream.h b/content/common/socket_stream.h
index 6999842..29d1860 100644
--- a/chrome/common/net/socket_stream.h
+++ b/content/common/socket_stream.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_COMMON_NET_SOCKET_STREAM_H_
-#define CHROME_COMMON_NET_SOCKET_STREAM_H_
+#ifndef CONTENT_COMMON_SOCKET_STREAM_H_
+#define CONTENT_COMMON_SOCKET_STREAM_H_
#pragma once
-namespace chrome_common_net {
+namespace content_common {
const int kNoSocketId = 0;
} // namespace chrome_common_net
-#endif // CHROME_COMMON_NET_SOCKET_STREAM_H_
+#endif // CONTENT_COMMON_SOCKET_STREAM_H_
diff --git a/content/common/socket_stream_messages.h b/content/common/socket_stream_messages.h
new file mode 100644
index 0000000..3da8983
--- /dev/null
+++ b/content/common/socket_stream_messages.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Multiply-included message file, hence no include guard.
+
+#include <vector>
+
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_param_traits.h"
+
+class GURL;
+
+#define IPC_MESSAGE_START SocketStreamMsgStart
+
+// Web Sockets messages sent from the renderer to the browser.
+
+// Open new Socket Stream for the |socket_url| identified by |socket_id|
+// in the renderer process.
+// The browser starts connecting asynchronously.
+// Once Socket Stream connection is established, the browser will send
+// SocketStreamMsg_Connected back.
+IPC_MESSAGE_CONTROL2(SocketStreamHostMsg_Connect,
+ GURL /* socket_url */,
+ int /* socket_id */)
+
+// Request to send data on the Socket Stream.
+// SocketStreamHandle can send data at most |max_pending_send_allowed| bytes,
+// which is given by ViewMsg_SocketStream_Connected at any time.
+// The number of pending bytes can be tracked by size of |data| sent
+// and |amount_sent| parameter of ViewMsg_SocketStream_DataSent.
+// That is, the following constraints is applied:
+// (accumulated total of |data|) - (accumulated total of |amount_sent|)
+// <= |max_pending_send_allowed|
+// If the SocketStreamHandle ever tries to exceed the
+// |max_pending_send_allowed|, the connection will be closed.
+IPC_MESSAGE_CONTROL2(SocketStreamHostMsg_SendData,
+ int /* socket_id */,
+ std::vector<char> /* data */)
+
+// Request to close the Socket Stream.
+// The browser will send ViewMsg_SocketStream_Closed back when the Socket
+// Stream is completely closed.
+IPC_MESSAGE_CONTROL1(SocketStreamHostMsg_Close,
+ int /* socket_id */)
+
+
+// Speech input messages sent from the browser to the renderer.
+
+// A |socket_id| is assigned by SocketStreamHostMsg_Connect.
+// The Socket Stream is connected. The SocketStreamHandle should keep track
+// of how much it has pending (how much it has requested to be sent) and
+// shouldn't go over |max_pending_send_allowed| bytes.
+IPC_MESSAGE_CONTROL2(SocketStreamMsg_Connected,
+ int /* socket_id */,
+ int /* max_pending_send_allowed */)
+
+// |data| is received on the Socket Stream.
+IPC_MESSAGE_CONTROL2(SocketStreamMsg_ReceivedData,
+ int /* socket_id */,
+ std::vector<char> /* data */)
+
+// |amount_sent| bytes of data requested by
+// SocketStreamHostMsg_SendData has been sent on the Socket Stream.
+IPC_MESSAGE_CONTROL2(SocketStreamMsg_SentData,
+ int /* socket_id */,
+ int /* amount_sent */)
+
+// The Socket Stream is closed.
+IPC_MESSAGE_CONTROL1(SocketStreamMsg_Closed,
+ int /* socket_id */)
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 477d460..8b8753e 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -14,14 +14,21 @@
'..',
],
'sources': [
- "common/content_switches.cc",
- "common/content_switches.h",
+ 'common/common_param_traits.cc',
+ 'common/common_param_traits.h',
+ 'common/content_message_generator.cc',
+ 'common/content_message_generator.h',
+ 'common/content_constants.cc',
+ 'common/content_constants.h',
+ 'common/content_switches.cc',
+ 'common/content_switches.h',
'common/message_router.cc',
'common/message_router.h',
- "common/p2p_messages.cc",
- "common/p2p_messages.h",
- "common/p2p_sockets.cc",
- "common/p2p_sockets.h",
+ 'common/p2p_messages.h',
+ 'common/p2p_sockets.cc',
+ 'common/p2p_sockets.h',
+ 'common/socket_stream.h',
+ 'common/socket_stream_messages.h',
],
'conditions': [
['OS=="win"', {
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 1b669f1..f7bf49a 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -70,6 +70,7 @@ enum IPCMessageStart {
AutoFillMsgStart,
SafeBrowsingMsgStart,
P2PMsgStart,
+ SocketStreamMsgStart,
};
class DictionaryValue;