diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 13:54:59 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 13:54:59 +0000 |
commit | 67a7851692243892bb2d7253d2f1974833e57432 (patch) | |
tree | 98bdc05f9af985cbcc8b9cc6ea0ccf472a85b588 /chrome/common | |
parent | e40cc399bd7e438579d6fcfa208103c12caf9052 (diff) | |
download | chromium_src-67a7851692243892bb2d7253d2f1974833e57432.zip chromium_src-67a7851692243892bb2d7253d2f1974833e57432.tar.gz chromium_src-67a7851692243892bb2d7253d2f1974833e57432.tar.bz2 |
Adds IDBKeyPath parser / extractor, and provides a mechanism to call it sandboxed.
TEST=idbkeypathextractor_browsertests.cc
Review URL: http://codereview.chromium.org/3043037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/indexed_db_param_traits.h | 102 | ||||
-rw-r--r-- | chrome/common/render_messages.cc | 83 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 18 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 1 | ||||
-rw-r--r-- | chrome/common/utility_messages.h | 1 | ||||
-rw-r--r-- | chrome/common/utility_messages_internal.h | 25 |
6 files changed, 131 insertions, 99 deletions
diff --git a/chrome/common/indexed_db_param_traits.h b/chrome/common/indexed_db_param_traits.h new file mode 100644 index 0000000..11d2050 --- /dev/null +++ b/chrome/common/indexed_db_param_traits.h @@ -0,0 +1,102 @@ +// 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. + +#ifndef CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_ +#define CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_ +#pragma once + +#include "chrome/common/indexed_db_key.h" +#include "chrome/common/serialized_script_value.h" + +namespace IPC { + +// These datatypes are used by utility_messages.h and render_messages.h. +// Unfortunately we can't move it to common: MSVC linker complains about +// WebKit datatypes that are not linked on npchrome_frame (even though it's +// never actually used by that target). + +template <> +struct ParamTraits<SerializedScriptValue> { + typedef SerializedScriptValue param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.is_null()); + WriteParam(m, p.is_invalid()); + WriteParam(m, p.data()); + } + static bool Read(const Message* m, void** iter, param_type* r) { + bool is_null; + bool is_invalid; + string16 data; + bool ok = + ReadParam(m, iter, &is_null) && + ReadParam(m, iter, &is_invalid) && + ReadParam(m, iter, &data); + if (!ok) + return false; + r->set_is_null(is_null); + r->set_is_invalid(is_invalid); + r->set_data(data); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<SerializedScriptValue>("); + LogParam(p.is_null(), l); + l->append(L", "); + LogParam(p.is_invalid(), l); + l->append(L", "); + LogParam(p.data(), l); + l->append(L")"); + } +}; + +template <> +struct ParamTraits<IndexedDBKey> { + typedef IndexedDBKey param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, int(p.type())); + // TODO(jorlow): Technically, we only need to pack the type being used. + WriteParam(m, p.string()); + WriteParam(m, p.number()); + } + static bool Read(const Message* m, void** iter, param_type* r) { + int type; + string16 string; + int32 number; + bool ok = + ReadParam(m, iter, &type) && + ReadParam(m, iter, &string) && + ReadParam(m, iter, &number); + if (!ok) + return false; + switch (type) { + case WebKit::WebIDBKey::NullType: + r->SetNull(); + return true; + case WebKit::WebIDBKey::StringType: + r->Set(string); + return true; + case WebKit::WebIDBKey::NumberType: + r->Set(number); + return true; + case WebKit::WebIDBKey::InvalidType: + r->SetInvalid(); + return true; + } + NOTREACHED(); + return false; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<IndexedDBKey>("); + LogParam(int(p.type()), l); + l->append(L", "); + LogParam(p.string(), l); + l->append(L", "); + LogParam(p.number(), l); + l->append(L")"); + } +}; + +} // namespace IPC + +#endif // CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_ diff --git a/chrome/common/render_messages.cc b/chrome/common/render_messages.cc index e3aec79..cb13959 100644 --- a/chrome/common/render_messages.cc +++ b/chrome/common/render_messages.cc @@ -8,8 +8,7 @@ #include "chrome/common/edit_command.h" #include "chrome/common/extensions/extension_extent.h" #include "chrome/common/extensions/url_pattern.h" -#include "chrome/common/indexed_db_key.h" -#include "chrome/common/serialized_script_value.h" +#include "chrome/common/indexed_db_param_traits.h" #include "chrome/common/thumbnail_score.h" #include "gfx/rect.h" #include "ipc/ipc_channel_handle.h" @@ -377,86 +376,6 @@ void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log( l->append(L"<HttpResponseHeaders>"); } -void ParamTraits<SerializedScriptValue>::Write(Message* m, const param_type& p) { - WriteParam(m, p.is_null()); - WriteParam(m, p.is_invalid()); - WriteParam(m, p.data()); -} - -bool ParamTraits<SerializedScriptValue>::Read(const Message* m, void** iter, - param_type* r) { - bool is_null; - bool is_invalid; - string16 data; - bool ok = - ReadParam(m, iter, &is_null) && - ReadParam(m, iter, &is_invalid) && - ReadParam(m, iter, &data); - if (!ok) - return false; - r->set_is_null(is_null); - r->set_is_invalid(is_invalid); - r->set_data(data); - return true; -} - -void ParamTraits<SerializedScriptValue>::Log(const param_type& p, - std::wstring* l) { - l->append(L"<SerializedScriptValue>("); - LogParam(p.is_null(), l); - l->append(L", "); - LogParam(p.is_invalid(), l); - l->append(L", "); - LogParam(p.data(), l); - l->append(L")"); -} - -void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { - WriteParam(m, int(p.type())); - // TODO(jorlow): Technically, we only need to pack the type being used. - WriteParam(m, p.string()); - WriteParam(m, p.number()); -} - -bool ParamTraits<IndexedDBKey>::Read(const Message* m, void** iter, - param_type* r) { - int type; - string16 string; - int32 number; - bool ok = - ReadParam(m, iter, &type) && - ReadParam(m, iter, &string) && - ReadParam(m, iter, &number); - if (!ok) - return false; - switch (type) { - case WebKit::WebIDBKey::NullType: - r->SetNull(); - return true; - case WebKit::WebIDBKey::StringType: - r->Set(string); - return true; - case WebKit::WebIDBKey::NumberType: - r->Set(number); - return true; - case WebKit::WebIDBKey::InvalidType: - r->SetInvalid(); - return true; - } - NOTREACHED(); - return false; -} - -void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::wstring* l) { - l->append(L"<IndexedDBKey>("); - LogParam(int(p.type()), l); - l->append(L", "); - LogParam(p.string(), l); - l->append(L", "); - LogParam(p.number(), l); - l->append(L")"); -} - void ParamTraits<webkit_glue::FormData>::Write(Message* m, const param_type& p) { WriteParam(m, p.name); diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 2a516ed..9d082bc 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -23,7 +23,7 @@ #include "chrome/common/dom_storage_common.h" #include "chrome/common/extensions/extension_extent.h" // used in struct #include "chrome/common/font_descriptor_mac.h" -#include "chrome/common/indexed_db_key.h" // used in struct +#include "chrome/common/indexed_db_param_traits.h" #include "chrome/common/navigation_gesture.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/renderer_preferences.h" // used in struct @@ -75,8 +75,6 @@ struct WebAccessibility; struct EditCommand; class ExtensionExtent; -class IndexedDBKey; -class SerializedScriptValue; class SkBitmap; class URLPattern; @@ -1497,21 +1495,7 @@ struct ParamTraits<SyncLoadResult> { } }; -template <> -struct ParamTraits<SerializedScriptValue> { - typedef SerializedScriptValue param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::wstring* l); -}; -template <> -struct ParamTraits<IndexedDBKey> { - typedef IndexedDBKey param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, void** iter, param_type* r); - static void Log(const param_type& p, std::wstring* l); -}; // Traits for FormData structure to pack/unpack. template <> diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index ba858bf..fb9e939 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -41,6 +41,7 @@ // Substitution map for l10n messages. typedef std::map<std::string, std::string> SubstitutionMap; +class SerializedScriptValue; class SkBitmap; struct ThumbnailScore; class WebCursor; diff --git a/chrome/common/utility_messages.h b/chrome/common/utility_messages.h index 03e0d0a..516081c 100644 --- a/chrome/common/utility_messages.h +++ b/chrome/common/utility_messages.h @@ -13,6 +13,7 @@ #include "base/values.h" #include "chrome/common/common_param_traits.h" #include "chrome/common/extensions/update_manifest.h" +#include "chrome/common/indexed_db_param_traits.h" #include "ipc/ipc_message_utils.h" namespace IPC { diff --git a/chrome/common/utility_messages_internal.h b/chrome/common/utility_messages_internal.h index 9231501..08dd347 100644 --- a/chrome/common/utility_messages_internal.h +++ b/chrome/common/utility_messages_internal.h @@ -48,6 +48,20 @@ IPC_BEGIN_MESSAGES(Utility) gfx::Rect, // Render Area int, // DPI std::vector<printing::PageRange>) + + // Tell the utility process to extract the given IDBKeyPath from the + // SerializedScriptValue vector and reply with the corresponding IDBKeys. + IPC_MESSAGE_CONTROL3(UtilityMsg_IDBKeysFromValuesAndKeyPath, + int, // id + std::vector<SerializedScriptValue>, + string16) // IDBKeyPath + + // Tells the utility process that it's running in batch mode. + IPC_MESSAGE_CONTROL0(UtilityMsg_BatchMode_Started) + + // Tells the utility process that it can shutdown. + IPC_MESSAGE_CONTROL0(UtilityMsg_BatchMode_Finished) + IPC_END_MESSAGES(Utility) //------------------------------------------------------------------------------ @@ -111,4 +125,15 @@ IPC_BEGIN_MESSAGES(UtilityHost) LOGFONT /* font data */) #endif // defined(OS_WIN) + // Reply when the utility process has succeeded in obtaining the value for + // IDBKeyPath. + IPC_MESSAGE_CONTROL2(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded, + int /* id */, + std::vector<IndexedDBKey> /* value */) + + // Reply when the utility process has failed in obtaining the value for + // IDBKeyPath. + IPC_MESSAGE_CONTROL1(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Failed, + int /* id */) + IPC_END_MESSAGES(UtilityHost) |