summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-15 04:50:34 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-15 04:50:34 +0000
commit4e6419cf5374adda16f97be965b8b7e5b225224f (patch)
tree594ced66460efaedf1071dd7468ba7012d0a6280 /chrome/renderer
parentfc105849740379470c96501032e377668a2f5e7e (diff)
downloadchromium_src-4e6419cf5374adda16f97be965b8b7e5b225224f.zip
chromium_src-4e6419cf5374adda16f97be965b8b7e5b225224f.tar.gz
chromium_src-4e6419cf5374adda16f97be965b8b7e5b225224f.tar.bz2
Introduce all the plumbing for Session Storage. This mostly consists of creating and tracking namespace ids in conjunction with the tabs. This is essentially just a bunch of dead code at the moment, but the next patch will get rid of the old way of generating/cloning IDs (initiated by the renderer) and instead use these IDs.
TEST=none BUG=none Review URL: http://codereview.chromium.org/550017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_thread.cc10
-rw-r--r--chrome/renderer/render_thread.h8
-rw-r--r--chrome/renderer/render_view.cc19
-rw-r--r--chrome/renderer/render_view.h11
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc6
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h1
-rw-r--r--chrome/renderer/renderer_webstoragenamespace_impl.cc20
-rw-r--r--chrome/renderer/renderer_webstoragenamespace_impl.h7
8 files changed, 36 insertions, 46 deletions
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 0a5fe6a..657e440 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -414,15 +414,13 @@ void RenderThread::OnSetCSSColors(
WebKit::setNamedColors(color_names.get(), web_colors.get(), num_colors);
}
-void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd,
- const RendererPreferences& renderer_prefs,
- const WebPreferences& webkit_prefs,
- int32 view_id) {
+void RenderThread::OnCreateNewView(const ViewMsg_New_Params& params) {
EnsureWebKitInitialized();
// When bringing in render_view, also bring in webkit's glue and jsbindings.
RenderView::Create(
- this, parent_hwnd, MSG_ROUTING_NONE, renderer_prefs,
- webkit_prefs, new SharedRenderViewCounter(0), view_id);
+ this, params.parent_window, MSG_ROUTING_NONE, params.renderer_preferences,
+ params.web_preferences, new SharedRenderViewCounter(0), params.view_id,
+ params.session_storage_namespace_id);
}
void RenderThread::OnSetCacheCapacities(size_t min_dead_capacity,
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index bde662a..559b7dc 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -18,7 +18,7 @@
#include "build/build_config.h"
#include "chrome/common/child_thread.h"
#include "chrome/common/css_colors.h"
-#include "chrome/common/dom_storage_type.h"
+#include "chrome/common/dom_storage_common.h"
#include "chrome/renderer/renderer_histogram_snapshots.h"
#include "chrome/renderer/visitedlink_slave.h"
#include "ipc/ipc_platform_file.h"
@@ -40,6 +40,7 @@ class URLPattern;
struct RendererPreferences;
struct ViewMsg_DOMStorageEvent_Params;
+struct ViewMsg_New_Params;
struct WebPreferences;
namespace WebKit {
@@ -171,10 +172,7 @@ class RenderThread : public RenderThreadBase,
const std::vector<URLPattern>& permissions);
void OnSetNextPageID(int32 next_page_id);
void OnSetCSSColors(const std::vector<CSSColors::CSSColorMapping>& colors);
- void OnCreateNewView(gfx::NativeViewId parent_hwnd,
- const RendererPreferences& renderer_prefs,
- const WebPreferences& webkit_prefs,
- int32 view_id);
+ void OnCreateNewView(const ViewMsg_New_Params& params);
void OnTransferBitmap(const SkBitmap& bitmap, int resource_id);
void OnSetCacheCapacities(size_t min_dead_capacity,
size_t max_dead_capacity,
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index f59d538..b1c2c01 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -246,7 +246,8 @@ static bool UrlMatchesPermissions(
int32 RenderView::next_page_id_ = 1;
RenderView::RenderView(RenderThreadBase* render_thread,
- const WebPreferences& webkit_preferences)
+ const WebPreferences& webkit_preferences,
+ int64 session_storage_namespace_id)
: RenderWidget(render_thread, true),
enabled_bindings_(0),
target_url_status_(TARGET_NONE),
@@ -281,6 +282,7 @@ RenderView::RenderView(RenderThreadBase* render_thread,
#endif
document_tag_(0),
webkit_preferences_(webkit_preferences),
+ session_storage_namespace_id_(session_storage_namespace_id),
ALLOW_THIS_IN_INITIALIZER_LIST(text_translator_(this)) {
page_translator_.reset(new PageTranslator(&text_translator_));
}
@@ -339,9 +341,11 @@ RenderView* RenderView::Create(
const RendererPreferences& renderer_prefs,
const WebPreferences& webkit_prefs,
SharedRenderViewCounter* counter,
- int32 routing_id) {
+ int32 routing_id,
+ int64 session_storage_namespace_id) {
DCHECK(routing_id != MSG_ROUTING_NONE);
- scoped_refptr<RenderView> view = new RenderView(render_thread, webkit_prefs);
+ scoped_refptr<RenderView> view = new RenderView(render_thread, webkit_prefs,
+ session_storage_namespace_id);
view->Init(parent_hwnd,
opener_id,
renderer_prefs,
@@ -1360,9 +1364,13 @@ WebView* RenderView::createView(WebFrame* creator) {
int32 routing_id = MSG_ROUTING_NONE;
bool user_gesture = creator->isProcessingUserGesture();
bool opener_suppressed = creator->willSuppressOpenerInNewFrame();
+ int64 cloned_session_storage_namespace_id;
render_thread_->Send(
- new ViewHostMsg_CreateWindow(routing_id_, user_gesture, &routing_id));
+ new ViewHostMsg_CreateWindow(routing_id_, user_gesture,
+ session_storage_namespace_id_,
+ &routing_id,
+ &cloned_session_storage_namespace_id));
if (routing_id == MSG_ROUTING_NONE)
return NULL;
@@ -1372,7 +1380,8 @@ WebView* RenderView::createView(WebFrame* creator) {
renderer_preferences_,
webkit_preferences_,
shared_popup_counter_,
- routing_id);
+ routing_id,
+ cloned_session_storage_namespace_id);
view->opened_by_user_gesture_ = user_gesture;
// Record whether the creator frame is trying to suppress the opener field.
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 7a4ebc4..0aca71f 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -143,7 +143,8 @@ class RenderView : public RenderWidget,
const RendererPreferences& renderer_prefs,
const WebPreferences& webkit_prefs,
SharedRenderViewCounter* counter,
- int32 routing_id);
+ int32 routing_id,
+ int64 session_storage_namespace_id);
// Sets the "next page id" counter.
static void SetNextPageID(int32 next_page_id);
@@ -469,7 +470,8 @@ class RenderView : public RenderWidget,
typedef std::map<std::string, int> HostZoomLevels;
explicit RenderView(RenderThreadBase* render_thread,
- const WebPreferences& webkit_preferences);
+ const WebPreferences& webkit_preferences,
+ int64 session_storage_namespace_id);
// Initializes this view with the given parent and ID. The |routing_id| can be
// set to 'MSG_ROUTING_NONE' if the true ID is not yet known. In this case,
@@ -1007,6 +1009,11 @@ class RenderView : public RenderWidget,
HostZoomLevels host_zoom_levels_;
+ // The SessionStorage namespace that we're assigned to has an ID, and that ID
+ // is passed to us upon creation. WebKit asks for this ID upon first use and
+ // uses it whenever asking the browser process to allocate new storage areas.
+ int64 session_storage_namespace_id_;
+
// Page translation related objects.
TextTranslatorImpl text_translator_;
scoped_ptr<PageTranslator> page_translator_;
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 8d20ee5..5580ab9 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -205,12 +205,6 @@ WebStorageNamespace* RendererWebKitClientImpl::createLocalStorageNamespace(
return new RendererWebStorageNamespaceImpl(DOM_STORAGE_LOCAL);
}
-WebStorageNamespace* RendererWebKitClientImpl::createSessionStorageNamespace() {
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
- return WebStorageNamespace::createSessionStorageNamespace();
- return new RendererWebStorageNamespaceImpl(DOM_STORAGE_SESSION);
-}
-
void RendererWebKitClientImpl::dispatchStorageEvent(
const WebString& key, const WebString& old_value,
const WebString& new_value, const WebString& origin,
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index 2388d07..add7ca5 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -51,7 +51,6 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual void suddenTerminationChanged(bool enabled);
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
const WebKit::WebString& path, unsigned quota);
- virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
virtual void dispatchStorageEvent(
const WebKit::WebString& key, const WebKit::WebString& old_value,
const WebKit::WebString& new_value, const WebKit::WebString& origin,
diff --git a/chrome/renderer/renderer_webstoragenamespace_impl.cc b/chrome/renderer/renderer_webstoragenamespace_impl.cc
index 41a8c6c..7bd704f 100644
--- a/chrome/renderer/renderer_webstoragenamespace_impl.cc
+++ b/chrome/renderer/renderer_webstoragenamespace_impl.cc
@@ -14,15 +14,16 @@ using WebKit::WebString;
RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl(
DOMStorageType storage_type)
- : storage_type_(storage_type),
- namespace_id_(kUninitializedNamespaceId) {
+ : storage_type_(storage_type) {
+ RenderThread::current()->Send(
+ new ViewHostMsg_DOMStorageNamespaceId(storage_type_,
+ &namespace_id_));
}
RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl(
DOMStorageType storage_type, int64 namespace_id)
: storage_type_(storage_type),
namespace_id_(namespace_id) {
- DCHECK(namespace_id_ != kUninitializedNamespaceId);
}
RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() {
@@ -30,15 +31,6 @@ RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() {
WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea(
const WebString& origin) {
- // This could be done async in the background (started when this class is
- // first instantiated) rather than lazily on first use, but it's unclear
- // whether it's worth the complexity.
- if (namespace_id_ == kUninitializedNamespaceId) {
- RenderThread::current()->Send(
- new ViewHostMsg_DOMStorageNamespaceId(storage_type_,
- &namespace_id_));
- DCHECK(namespace_id_ != kUninitializedNamespaceId);
- }
// Ideally, we'd keep a hash map of origin to these objects. Unfortunately
// this doesn't seem practical because there's no good way to ref-count these
// objects, and it'd be unclear who owned them. So, instead, we'll pay a
@@ -47,10 +39,6 @@ WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea(
}
WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() {
- // If we haven't been used yet, we might as well start out fresh (and lazy).
- if (namespace_id_ == kUninitializedNamespaceId)
- return new RendererWebStorageNamespaceImpl(storage_type_);
-
// This cannot easily be deferred because we need a snapshot in time.
int64 new_namespace_id;
RenderThread::current()->Send(
diff --git a/chrome/renderer/renderer_webstoragenamespace_impl.h b/chrome/renderer/renderer_webstoragenamespace_impl.h
index 391a157..ced7203 100644
--- a/chrome/renderer/renderer_webstoragenamespace_impl.h
+++ b/chrome/renderer/renderer_webstoragenamespace_impl.h
@@ -6,7 +6,7 @@
#define CHROME_RENDERER_RENDERER_WEBSTORAGENAMESPACE_IMPL_H_
#include "base/basictypes.h"
-#include "chrome/common/dom_storage_type.h"
+#include "chrome/common/dom_storage_common.h"
#include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h"
class RendererWebStorageNamespaceImpl : public WebKit::WebStorageNamespace {
@@ -26,11 +26,8 @@ class RendererWebStorageNamespaceImpl : public WebKit::WebStorageNamespace {
// Used during lazy initialization of namespace_id_.
const DOMStorageType storage_type_;
- // Our namespace ID. Lazily initialized.
+ // Our namespace ID.
int64 namespace_id_;
-
- // namespace_id_ should equal this iff its unitialized.
- static const int64 kUninitializedNamespaceId = -1;
};
#endif // CHROME_RENDERER_RENDERER_WEBSTORAGENAMESPACE_IMPL_H_