diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-15 04:50:34 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-15 04:50:34 +0000 |
commit | 4e6419cf5374adda16f97be965b8b7e5b225224f (patch) | |
tree | 594ced66460efaedf1071dd7468ba7012d0a6280 | |
parent | fc105849740379470c96501032e377668a2f5e7e (diff) | |
download | chromium_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
39 files changed, 284 insertions, 125 deletions
diff --git a/chrome/browser/chromeos/main_menu.cc b/chrome/browser/chromeos/main_menu.cc index 051e554..eae51c9 100644 --- a/chrome/browser/chromeos/main_menu.cc +++ b/chrome/browser/chromeos/main_menu.cc @@ -14,6 +14,8 @@ #include "base/string_util.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser.h" +#include "chrome/browser/in_process_webkit/dom_storage_context.h" +#include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_view_host_factory.h" @@ -148,8 +150,11 @@ MainMenu::MainMenu() DCHECK(BrowserList::begin() != BrowserList::end()); // TODO(sky): this shouldn't pick a random profile to use. Profile* profile = (*BrowserList::begin())->profile(); + int64 session_storage_namespace_id = profile->GetWebKitContext()-> + dom_storage_context()->AllocateSessionStorageNamespaceId(); site_instance_ = SiteInstance::CreateSiteInstanceForURL(profile, menu_url); - menu_rvh_ = new RenderViewHost(site_instance_, this, MSG_ROUTING_NONE); + menu_rvh_ = new RenderViewHost(site_instance_, this, MSG_ROUTING_NONE, + session_storage_namespace_id); rwhv_ = new RenderWidgetHostViewGtk(menu_rvh_); rwhv_->InitAsChild(); diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index d7716be..e7ca8f0 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -21,6 +21,8 @@ #include "chrome/browser/dom_ui/dom_ui_factory.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extension_tabs_module.h" +#include "chrome/browser/in_process_webkit/dom_storage_context.h" +#include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/jsmessage_box_handler.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" @@ -123,7 +125,10 @@ ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance, document_element_available_(false), url_(url), extension_host_type_(host_type) { - render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE); + int64 session_storage_namespace_id = profile_->GetWebKitContext()-> + dom_storage_context()->AllocateSessionStorageNamespaceId(); + render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE, + session_storage_namespace_id); render_view_host_->AllowBindings(BindingsPolicy::EXTENSION); if (enable_dom_automation_) render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION); diff --git a/chrome/browser/in_process_webkit/dom_storage_context.cc b/chrome/browser/in_process_webkit/dom_storage_context.cc index b695f9f..15099c2 100644 --- a/chrome/browser/in_process_webkit/dom_storage_context.cc +++ b/chrome/browser/in_process_webkit/dom_storage_context.cc @@ -10,6 +10,7 @@ #include "chrome/browser/in_process_webkit/dom_storage_area.h" #include "chrome/browser/in_process_webkit/dom_storage_namespace.h" #include "chrome/browser/in_process_webkit/webkit_context.h" +#include "chrome/common/dom_storage_common.h" static const char* kLocalStorageDirectory = "Local Storage"; @@ -24,8 +25,9 @@ static void MigrateLocalStorageDirectory(const FilePath& data_path) { } DOMStorageContext::DOMStorageContext(WebKitContext* webkit_context) - : last_storage_area_id_(kFirstStorageAreaId), - last_storage_namespace_id_(kFirstStorageNamespaceId), + : last_storage_area_id_(0), + last_session_storage_namespace_id_on_ui_thread_(kLocalStorageNamespaceId), + last_session_storage_namespace_id_on_io_thread_(kLocalStorageNamespaceId), webkit_context_(webkit_context) { } @@ -67,6 +69,27 @@ DOMStorageNamespace* DOMStorageContext::NewSessionStorage() { return DOMStorageNamespace::CreateSessionStorageNamespace(this); } +int64 DOMStorageContext::AllocateStorageAreaId() { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); + return ++last_storage_area_id_; +} + +int64 DOMStorageContext::AllocateSessionStorageNamespaceId() { + if (ChromeThread::CurrentlyOn(ChromeThread::UI)) + return ++last_session_storage_namespace_id_on_ui_thread_; + return --last_session_storage_namespace_id_on_io_thread_; +} + +int64 DOMStorageContext::CloneSessionStorage(int64 original_id) { + DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); + int64 clone_id = AllocateSessionStorageNamespaceId(); + ChromeThread::PostTask( + ChromeThread::WEBKIT, FROM_HERE, NewRunnableFunction( + &DOMStorageContext::CompleteCloningSessionStorage, + this, original_id, clone_id)); + return clone_id; +} + void DOMStorageContext::RegisterStorageArea(DOMStorageArea* storage_area) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); int64 id = storage_area->id(); @@ -162,3 +185,13 @@ void DOMStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) { file_util::Delete(path, false); } } + +void DOMStorageContext::CompleteCloningSessionStorage( + DOMStorageContext* context, int64 existing_id, int64 clone_id) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); + DOMStorageNamespace* existing_namespace = + context->GetStorageNamespace(existing_id); + // If nothing exists, then there's nothing to clone. + if (existing_namespace) + existing_namespace->Copy(clone_id); +} diff --git a/chrome/browser/in_process_webkit/dom_storage_context.h b/chrome/browser/in_process_webkit/dom_storage_context.h index 9838930..df472f3 100644 --- a/chrome/browser/in_process_webkit/dom_storage_context.h +++ b/chrome/browser/in_process_webkit/dom_storage_context.h @@ -34,9 +34,15 @@ class DOMStorageContext { // Get a new session storage namespace (but it's still owned by this class). DOMStorageNamespace* NewSessionStorage(); - // Allocate a new storage ___ id. - int64 AllocateStorageAreaId() { return ++last_storage_area_id_; } - int64 AllocateStorageNamespaceId() { return ++last_storage_namespace_id_; } + // Allocate a new storage area id. Only call on the WebKit thread. + int64 AllocateStorageAreaId(); + + // Allocate a new session storage id. Only call on the UI or IO thread. + int64 AllocateSessionStorageNamespaceId(); + + // Clones a session storage namespace and returns the cloned namespaces' id. + // Only call on the IO thread. + int64 CloneSessionStorage(int64 original_id); // Various storage area methods. The storage area is owned by one of the // namespaces that's owned by this class. @@ -65,15 +71,22 @@ class DOMStorageContext { // date that's supplied. void DeleteDataModifiedSince(const base::Time& cutoff); - // The special ID used for local storage. - static const int64 kLocalStorageNamespaceId = 0; - private: - // The last used storage_area_id and storage_namespace_id's. - static const int64 kFirstStorageAreaId = 1; + // The WebKit thread half of CloneSessionStorage above. Static because + // DOMStorageContext isn't ref counted thus we can't use a runnable method. + // That said, we know this is safe because this class is destroyed on the + // WebKit thread, so there's no way it could be destroyed before this is run. + static void CompleteCloningSessionStorage(DOMStorageContext* context, + int64 existing_id, int64 clone_id); + + // The last used storage_area_id and storage_namespace_id's. For the storage + // namespaces, IDs allocated on the UI thread are positive and count up while + // IDs allocated on the IO thread are negative and count down. This allows us + // to allocate unique IDs on both without any locking. All storage area ids + // are allocated on the WebKit thread. int64 last_storage_area_id_; - static const int64 kFirstStorageNamespaceId = 1; - int64 last_storage_namespace_id_; + int64 last_session_storage_namespace_id_on_ui_thread_; + int64 last_session_storage_namespace_id_on_io_thread_; // We're owned by this WebKit context. Used while instantiating LocalStorage. WebKitContext* webkit_context_; diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc index 28005b4..dc8e3f3 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc @@ -129,6 +129,10 @@ bool DOMStorageDispatcherHost::OnMessageReceived(const IPC::Message& message, return handled; } +int64 DOMStorageDispatcherHost::CloneSessionStorage(int64 original_id) { + return Context()->CloneSessionStorage(original_id); +} + void DOMStorageDispatcherHost::Send(IPC::Message* message) { if (!message_sender_) { delete message; diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h index 029a122..24aa739 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h @@ -10,7 +10,7 @@ #include "base/tracked.h" #include "chrome/browser/in_process_webkit/dom_storage_area.h" #include "chrome/browser/in_process_webkit/webkit_context.h" -#include "chrome/common/dom_storage_type.h" +#include "chrome/common/dom_storage_common.h" #include "ipc/ipc_message.h" class DOMStorageContext; @@ -39,6 +39,10 @@ class DOMStorageDispatcherHost // Only call from ResourceMessageFilter on the IO thread. bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); + // Clones a session storage namespace and returns the cloned namespaces' id. + // Only call on the IO thread. + int64 CloneSessionStorage(int64 original_id); + // Send a message to the renderer process associated with our // message_sender_ via the IO thread. May be called from any thread. void Send(IPC::Message* message); diff --git a/chrome/browser/in_process_webkit/dom_storage_namespace.cc b/chrome/browser/in_process_webkit/dom_storage_namespace.cc index f6e9ae5..924d954 100644 --- a/chrome/browser/in_process_webkit/dom_storage_namespace.cc +++ b/chrome/browser/in_process_webkit/dom_storage_namespace.cc @@ -19,7 +19,7 @@ using WebKit::WebString; /* static */ DOMStorageNamespace* DOMStorageNamespace::CreateLocalStorageNamespace( DOMStorageContext* dom_storage_context, const FilePath& data_dir_path) { - int64 id = dom_storage_context->kLocalStorageNamespaceId; + int64 id = kLocalStorageNamespaceId; DCHECK(!dom_storage_context->GetStorageNamespace(id)); return new DOMStorageNamespace(dom_storage_context, id, webkit_glue::FilePathToWebString(data_dir_path), DOM_STORAGE_LOCAL); @@ -28,7 +28,7 @@ DOMStorageNamespace* DOMStorageNamespace::CreateLocalStorageNamespace( /* static */ DOMStorageNamespace* DOMStorageNamespace::CreateSessionStorageNamespace( DOMStorageContext* dom_storage_context) { - int64 id = dom_storage_context->AllocateStorageNamespaceId(); + int64 id = dom_storage_context->AllocateSessionStorageNamespaceId(); DCHECK(!dom_storage_context->GetStorageNamespace(id)); return new DOMStorageNamespace(dom_storage_context, id, WebString(), DOM_STORAGE_SESSION); @@ -71,9 +71,14 @@ DOMStorageArea* DOMStorageNamespace::GetStorageArea(const string16& origin) { return storage_area; } +// TODO(jorlow): Remove in the next patch. DOMStorageNamespace* DOMStorageNamespace::Copy() { + int64 id = dom_storage_context_->AllocateSessionStorageNamespaceId(); + return Copy(id); +} + +DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) { DCHECK(dom_storage_type_ == DOM_STORAGE_SESSION); - int64 id = dom_storage_context_->AllocateStorageNamespaceId(); DCHECK(!dom_storage_context_->GetStorageNamespace(id)); DOMStorageNamespace* new_storage_namespace = new DOMStorageNamespace( dom_storage_context_, id, data_dir_path_, dom_storage_type_); diff --git a/chrome/browser/in_process_webkit/dom_storage_namespace.h b/chrome/browser/in_process_webkit/dom_storage_namespace.h index a41dcd7..c317c67 100644 --- a/chrome/browser/in_process_webkit/dom_storage_namespace.h +++ b/chrome/browser/in_process_webkit/dom_storage_namespace.h @@ -8,7 +8,7 @@ #include "base/string16.h" #include "base/hash_tables.h" #include "base/scoped_ptr.h" -#include "chrome/common/dom_storage_type.h" +#include "chrome/common/dom_storage_common.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" class DOMStorageArea; @@ -31,7 +31,8 @@ class DOMStorageNamespace { ~DOMStorageNamespace(); DOMStorageArea* GetStorageArea(const string16& origin); - DOMStorageNamespace* Copy(); + DOMStorageNamespace* Copy(); // TODO(jorlow): Delete in next patch. + DOMStorageNamespace* Copy(int64 id); void PurgeMemory(); const DOMStorageContext* dom_storage_context() const { diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 5d46ccc..842e7b4 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -104,7 +104,8 @@ RenderViewHost* RenderViewHost::FromID(int render_process_id, RenderViewHost::RenderViewHost(SiteInstance* instance, RenderViewHostDelegate* delegate, - int routing_id) + int routing_id, + int64 session_storage_namespace_id) : RenderWidgetHost(instance->GetProcess(), routing_id), instance_(instance), delegate_(delegate), @@ -118,7 +119,8 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, is_waiting_for_unload_ack_(false), unload_ack_is_for_cross_site_transition_(false), are_javascript_messages_suppressed_(false), - sudden_termination_allowed_(false) { + sudden_termination_allowed_(false), + session_storage_namespace_id_(session_storage_namespace_id) { DCHECK(instance_); DCHECK(delegate_); @@ -205,10 +207,14 @@ bool RenderViewHost::CreateRenderView( webkit_prefs.databases_enabled = true; } - Send(new ViewMsg_New(GetNativeViewId(), - delegate_->GetRendererPrefs(process()->profile()), - webkit_prefs, - routing_id())); + ViewMsg_New_Params params; + params.parent_window = GetNativeViewId(); + params.renderer_preferences = + delegate_->GetRendererPrefs(process()->profile()); + params.web_preferences = webkit_prefs; + params.view_id = routing_id(); + params.session_storage_namespace_id = session_storage_namespace_id_; + Send(new ViewMsg_New(params)); // Set the alternate error page, which is profile specific, in the renderer. GURL url = delegate_->GetAlternateErrorPageURL(); diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index cfd1a77..831bd80 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -92,7 +92,8 @@ class RenderViewHost : public RenderWidgetHost, // which case RenderWidgetHost will create a new one. RenderViewHost(SiteInstance* instance, RenderViewHostDelegate* delegate, - int routing_id); + int routing_id, + int64 session_storage_namespace_id); virtual ~RenderViewHost(); SiteInstance* site_instance() const { return instance_; } @@ -671,6 +672,9 @@ class RenderViewHost : public RenderWidgetHost, NotificationRegistrar registrar_; + // The session storage namespace id to be used by the associated render view. + int64 session_storage_namespace_id_; + DISALLOW_COPY_AND_ASSIGN(RenderViewHost); }; diff --git a/chrome/browser/renderer_host/render_view_host_factory.cc b/chrome/browser/renderer_host/render_view_host_factory.cc index 01e8a18..4331f2d 100644 --- a/chrome/browser/renderer_host/render_view_host_factory.cc +++ b/chrome/browser/renderer_host/render_view_host_factory.cc @@ -14,11 +14,14 @@ RenderViewHostFactory* RenderViewHostFactory::factory_ = NULL; RenderViewHost* RenderViewHostFactory::Create( SiteInstance* instance, RenderViewHostDelegate* delegate, - int routing_id) { + int routing_id, + int64 session_storage_namespace_id) { if (factory_) { - return factory_->CreateRenderViewHost(instance, delegate, routing_id); + return factory_->CreateRenderViewHost(instance, delegate, routing_id, + session_storage_namespace_id); } - return new RenderViewHost(instance, delegate, routing_id); + return new RenderViewHost(instance, delegate, routing_id, + session_storage_namespace_id); } // static diff --git a/chrome/browser/renderer_host/render_view_host_factory.h b/chrome/browser/renderer_host/render_view_host_factory.h index 5e55054..4adf23d 100644 --- a/chrome/browser/renderer_host/render_view_host_factory.h +++ b/chrome/browser/renderer_host/render_view_host_factory.h @@ -25,7 +25,8 @@ class RenderViewHostFactory { // pointer will be passed to the caller. static RenderViewHost* Create(SiteInstance* instance, RenderViewHostDelegate* delegate, - int routing_id); + int routing_id, + int64 session_storage_namespace_id); // Returns true if there is currently a globally-registered factory. static bool has_factory() { @@ -41,7 +42,8 @@ class RenderViewHostFactory { virtual RenderViewHost* CreateRenderViewHost( SiteInstance* instance, RenderViewHostDelegate* delegate, - int routing_id) = 0; + int routing_id, + int64 session_storage_namespace_id) = 0; // Registers your factory to be called when new RenderViewHosts are created. // We have only one global factory, so there must be no factory registered diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 5c46a53..eafa767 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -461,7 +461,10 @@ URLRequestContext* ResourceMessageFilter::GetRequestContext( } void ResourceMessageFilter::OnMsgCreateWindow( - int opener_id, bool user_gesture, int* route_id) { + int opener_id, bool user_gesture, int64 session_storage_namespace_id, + int* route_id, int64* cloned_session_storage_namespace_id) { + *cloned_session_storage_namespace_id = dom_storage_dispatcher_host_-> + CloneSessionStorage(session_storage_namespace_id); render_widget_helper_->CreateNewWindow(opener_id, user_gesture, handle(), diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 4a97cb4..b24d095 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -118,7 +118,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, virtual ~ResourceMessageFilter(); - void OnMsgCreateWindow(int opener_id, bool user_gesture, int* route_id); + void OnMsgCreateWindow(int opener_id, bool user_gesture, + int64 session_storage_namespace_id, int* route_id, + int64* cloned_session_storage_namespace_id); void OnMsgCreateWidget(int opener_id, bool activatable, int* route_id); void OnSetCookie(const GURL& url, const GURL& first_party_for_cookies, diff --git a/chrome/browser/renderer_host/test/test_render_view_host.cc b/chrome/browser/renderer_host/test/test_render_view_host.cc index 095c2e1..95c5b7b 100644 --- a/chrome/browser/renderer_host/test/test_render_view_host.cc +++ b/chrome/browser/renderer_host/test/test_render_view_host.cc @@ -7,6 +7,7 @@ #include "base/gfx/rect.h" #include "chrome/browser/renderer_host/test/test_backing_store.h" #include "chrome/browser/tab_contents/test_tab_contents.h" +#include "chrome/common/dom_storage_common.h" #include "chrome/common/render_messages.h" using webkit_glue::PasswordForm; @@ -14,7 +15,8 @@ using webkit_glue::PasswordForm; TestRenderViewHost::TestRenderViewHost(SiteInstance* instance, RenderViewHostDelegate* delegate, int routing_id) - : RenderViewHost(instance, delegate, routing_id), + : RenderViewHost(instance, delegate, routing_id, + kInvalidSessionStorageNamespaceId), render_view_created_(false), delete_counter_(NULL) { set_view(new TestRenderWidgetHostView(this)); diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h index 9990fab..ca63c53 100644 --- a/chrome/browser/renderer_host/test/test_render_view_host.h +++ b/chrome/browser/renderer_host/test/test_render_view_host.h @@ -173,7 +173,8 @@ class TestRenderViewHostFactory : public RenderViewHostFactory { virtual RenderViewHost* CreateRenderViewHost( SiteInstance* instance, RenderViewHostDelegate* delegate, - int routing_id) { + int routing_id, + int64 session_storage_namespace_id) { // See declaration of render_process_host_factory_ below. instance->set_render_process_host_factory(render_process_host_factory_); return new TestRenderViewHost(instance, delegate, routing_id); diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 55972f3..f6db824 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -23,6 +23,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/common/bindings_policy.h" +#include "chrome/common/dom_storage_common.h" #if defined(TOOLKIT_GTK) #include "chrome/browser/gtk/gtk_theme_provider.h" #endif @@ -383,7 +384,7 @@ void InterstitialPage::DomOperationResponse(const std::string& json_string, RenderViewHost* InterstitialPage::CreateRenderViewHost() { RenderViewHost* render_view_host = new RenderViewHost( SiteInstance::CreateSiteInstance(tab()->profile()), - this, MSG_ROUTING_NONE); + this, MSG_ROUTING_NONE, kInvalidSessionStorageNamespaceId); return render_view_host; } diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index fa4c783..3cbe29c 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -12,6 +12,8 @@ #include "chrome/browser/browser_about_handler.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_url_handler.h" +#include "chrome/browser/in_process_webkit/dom_storage_context.h" +#include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/sessions/session_types.h" @@ -133,7 +135,9 @@ NavigationController::NavigationController(TabContents* contents, max_restored_page_id_(-1), ALLOW_THIS_IN_INITIALIZER_LIST(ssl_manager_(this)), needs_reload_(false), - user_gesture_observed_(false) { + user_gesture_observed_(false), + session_storage_namespace_id_(profile->GetWebKitContext()-> + dom_storage_context()->AllocateSessionStorageNamespaceId()) { DCHECK(profile_); } @@ -856,6 +860,10 @@ void NavigationController::CopyStateFrom(const NavigationController& source) { new NavigationEntry(*source.entries_[i]))); } + session_storage_namespace_id_ = + profile_->GetWebKitContext()->dom_storage_context()->CloneSessionStorage( + source.session_storage_namespace_id_); + FinishRestore(source.last_committed_entry_index_, false); } diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h index 59af542..5378546 100644 --- a/chrome/browser/tab_contents/navigation_controller.h +++ b/chrome/browser/tab_contents/navigation_controller.h @@ -374,6 +374,11 @@ class NavigationController { // if it was restored from a previous session. (-1 otherwise) int max_restored_page_id() const { return max_restored_page_id_; } + // The session storage namespace id that all child render views should use. + int64 session_storage_namespace_id() const { + return session_storage_namespace_id_; + } + // Disables checking for a repost and prompting the user. This is used during // testing. static void DisablePromptOnRepost(); @@ -528,6 +533,9 @@ class NavigationController { // Whether a user gesture has been observed since the last navigation. bool user_gesture_observed_; + // The session storage id that any (indirectly) owned RenderView should use. + int64 session_storage_namespace_id_; + // Should Reload check for post data? The default is true, but is set to false // when testing. static bool check_for_repost_; diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc index 8622f39..6fec169 100644 --- a/chrome/browser/tab_contents/render_view_host_manager.cc +++ b/chrome/browser/tab_contents/render_view_host_manager.cc @@ -55,7 +55,8 @@ void RenderViewHostManager::Init(Profile* profile, if (!site_instance) site_instance = SiteInstance::CreateSiteInstance(profile); render_view_host_ = RenderViewHostFactory::Create( - site_instance, render_view_delegate_, routing_id); + site_instance, render_view_delegate_, routing_id, delegate_-> + GetControllerForRenderManager().session_storage_namespace_id()); NotificationService::current()->Notify( NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB, Source<RenderViewHostManager>(this), @@ -412,7 +413,8 @@ bool RenderViewHostManager::CreatePendingRenderView(SiteInstance* instance) { } pending_render_view_host_ = RenderViewHostFactory::Create( - instance, render_view_delegate_, MSG_ROUTING_NONE); + instance, render_view_delegate_, MSG_ROUTING_NONE, delegate_-> + GetControllerForRenderManager().session_storage_namespace_id()); NotificationService::current()->Notify( NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB, Source<RenderViewHostManager>(this), diff --git a/chrome/browser/views/notifications/balloon_view_host.cc b/chrome/browser/views/notifications/balloon_view_host.cc index e825399..0a02d63 100644 --- a/chrome/browser/views/notifications/balloon_view_host.cc +++ b/chrome/browser/views/notifications/balloon_view_host.cc @@ -6,6 +6,8 @@ #include "base/string_util.h" #include "chrome/browser/browser_list.h" +#include "chrome/browser/in_process_webkit/dom_storage_context.h" +#include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/notifications/balloon.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/profile.h" @@ -100,8 +102,11 @@ void BalloonViewHost::UpdatePreferredSize(const gfx::Size& new_size) { void BalloonViewHost::Init(gfx::NativeView parent_hwnd) { DCHECK(!render_view_host_) << "BalloonViewHost already initialized."; + int64 session_storage_namespace_id = balloon_->profile()->GetWebKitContext()-> + dom_storage_context()->AllocateSessionStorageNamespaceId(); RenderViewHost* rvh = new RenderViewHost(site_instance_.get(), - this, MSG_ROUTING_NONE); + this, MSG_ROUTING_NONE, + session_storage_namespace_id); render_view_host_ = rvh; // Pointer is owned by the RVH. diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index adfa960b..1355cb1 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -200,7 +200,7 @@ 'common/css_colors.h', 'common/db_message_filter.cc', 'common/db_message_filter.h', - 'common/dom_storage_type.h', + 'common/dom_storage_common.h', 'common/filter_policy.h', 'common/gears_api.h', 'common/gpu_plugin.cc', diff --git a/chrome/common/dom_storage_common.h b/chrome/common/dom_storage_common.h new file mode 100644 index 0000000..96fc508 --- /dev/null +++ b/chrome/common/dom_storage_common.h @@ -0,0 +1,16 @@ +// Copyright (c) 2009 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_DOM_STORAGE_COMMON_H_ +#define CHROME_COMMON_DOM_STORAGE_COMMON_H_ + +const int64 kLocalStorageNamespaceId = 0; +const int64 kInvalidSessionStorageNamespaceId = kLocalStorageNamespaceId; + +enum DOMStorageType { + DOM_STORAGE_LOCAL = 0, + DOM_STORAGE_SESSION +}; + +#endif // CHROME_COMMON_DOM_STORAGE_COMMON_H_ diff --git a/chrome/common/dom_storage_type.h b/chrome/common/dom_storage_type.h deleted file mode 100644 index 0049fc4..0000000 --- a/chrome/common/dom_storage_type.h +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2009 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_DOM_STORAGE_TYPE_H_ -#define CHROME_COMMON_DOM_STORAGE_TYPE_H_ - -enum DOMStorageType { - DOM_STORAGE_LOCAL = 0, - DOM_STORAGE_SESSION -}; - -#endif // CHROME_COMMON_DOM_STORAGE_TYPE_H_ diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 3934b53..88288e9 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -19,7 +19,7 @@ #include "chrome/browser/renderer_host/resource_handler.h" #include "chrome/common/common_param_traits.h" #include "chrome/common/css_colors.h" -#include "chrome/common/dom_storage_type.h" +#include "chrome/common/dom_storage_common.h" #include "chrome/common/edit_command.h" #include "chrome/common/extensions/url_pattern.h" #include "chrome/common/filter_policy.h" @@ -534,6 +534,24 @@ struct ViewMsg_ExecuteCode_Params { bool all_frames; }; +// Creates a new view via a control message since the view doesn't yet exist. +struct ViewMsg_New_Params { + // The parent window's id. + gfx::NativeViewId parent_window; + + // Renderer-wide preferences. + RendererPreferences renderer_preferences; + + // Preferences for this view. + WebPreferences web_preferences; + + // The ID of the view to be created. + int32 view_id; + + // The session storage namespace ID this view should use. + int64 session_storage_namespace_id; +}; + // Message to ask the browser to translate some text from one language to // another. struct ViewHostMsg_TranslateTextParam { @@ -2317,7 +2335,6 @@ struct ParamTraits<ViewMsg_ExecuteCode_Params> { WriteParam(m, p.code); WriteParam(m, p.all_frames); } - static bool Read(const Message* m, void** iter, param_type* p) { return ReadParam(m, iter, &p->request_id) && @@ -2333,6 +2350,40 @@ struct ParamTraits<ViewMsg_ExecuteCode_Params> { }; template<> +struct ParamTraits<ViewMsg_New_Params> { + typedef ViewMsg_New_Params param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.parent_window); + WriteParam(m, p.renderer_preferences); + WriteParam(m, p.web_preferences); + WriteParam(m, p.view_id); + WriteParam(m, p.session_storage_namespace_id); + } + + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->parent_window) && + ReadParam(m, iter, &p->renderer_preferences) && + ReadParam(m, iter, &p->web_preferences) && + ReadParam(m, iter, &p->view_id) && + ReadParam(m, iter, &p->session_storage_namespace_id); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.parent_window, l); + l->append(L", "); + LogParam(p.renderer_preferences, l); + l->append(L", "); + LogParam(p.web_preferences, l); + l->append(L", "); + LogParam(p.view_id, l); + l->append(L", "); + LogParam(p.session_storage_namespace_id, l); + l->append(L")"); + } +}; + +template<> struct ParamTraits<ViewHostMsg_TranslateTextParam> { typedef ViewHostMsg_TranslateTextParam param_type; static void Write(Message* m, const param_type& p) { @@ -2370,7 +2421,6 @@ struct ParamTraits<ViewHostMsg_TranslateTextParam> { } }; - } // namespace IPC diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 5bd469d..2003c9d 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -70,13 +70,11 @@ IPC_BEGIN_MESSAGES(View) std::vector<CSSColors::CSSColorMapping>) // Tells the renderer to create a new view. - // This message is slightly different, the view it takes is the view to - // create, the message itself is sent as a non-view control message. - IPC_MESSAGE_CONTROL4(ViewMsg_New, - gfx::NativeViewId, /* parent window */ - RendererPreferences, - WebPreferences, - int32 /* view id */) + // This message is slightly different, the view it takes (via + // ViewMsg_New_Params) is the view to create, the message itself is sent as a + // non-view control message. + IPC_MESSAGE_CONTROL1(ViewMsg_New, + ViewMsg_New_Params) // Tells the renderer to set its maximum cache size to the supplied value IPC_MESSAGE_CONTROL3(ViewMsg_SetCacheCapacities, @@ -853,10 +851,12 @@ IPC_BEGIN_MESSAGES(ViewHost) // Sent by the renderer when it is creating a new window. The browser creates // a tab for it and responds with a ViewMsg_CreatingNew_ACK. If route_id is // MSG_ROUTING_NONE, the view couldn't be created. - IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateWindow, + IPC_SYNC_MESSAGE_CONTROL3_2(ViewHostMsg_CreateWindow, int /* opener_id */, bool /* user_gesture */, - int /* route_id */) + int64 /* session_storage_namespace_id */, + int /* route_id */, + int64 /* cloned_session_storage_namespace_id */) // Similar to ViewHostMsg_CreateWindow, except used for sub-widgets, like // <select> dropdowns. This message is sent to the TabContents that 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_ diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc index 883be1a..001e7b1 100644 --- a/chrome/test/render_view_test.cc +++ b/chrome/test/render_view_test.cc @@ -96,7 +96,8 @@ void RenderViewTest::SetUp() { // This needs to pass the mock render thread to the view. view_ = RenderView::Create(&render_thread_, 0, kOpenerId, RendererPreferences(), WebPreferences(), - new SharedRenderViewCounter(0), kRouteId); + new SharedRenderViewCounter(0), kRouteId, + kInvalidSessionStorageNamespaceId); // Attach a pseudo keyboard device to this object. mock_keyboard_.reset(new MockKeyboard()); diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 77fdd40..3e38d3e 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -13,6 +13,7 @@ #include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/favicon_service.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/net/url_request_context_getter.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url_model.h" @@ -200,7 +201,11 @@ class TestingProfile : public Profile { virtual void ResetTabRestoreService() {} virtual SpellCheckHost* GetSpellCheckHost() { return NULL; } virtual void ReinitializeSpellCheckHost(bool force) { } - virtual WebKitContext* GetWebKitContext() { return NULL; } + virtual WebKitContext* GetWebKitContext() { + if (webkit_context_ == NULL) + webkit_context_ = new WebKitContext(GetPath(), false); + return webkit_context_; + } virtual WebKitContext* GetOffTheRecordWebKitContext() { return NULL; } virtual void MarkAsCleanShutdown() {} virtual void InitExtensions() {} @@ -270,6 +275,9 @@ class TestingProfile : public Profile { // The main database tracker for this profile. // Should be used only on the file thread. scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; + + // WebKitContext, lazily initialized by GetWebKitContext(). + scoped_refptr<WebKitContext> webkit_context_; }; // A profile that derives from another profile. This does not actually diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc index fbc6505..4762ba7 100644 --- a/chrome/worker/worker_webkitclient_impl.cc +++ b/chrome/worker/worker_webkitclient_impl.cc @@ -89,11 +89,6 @@ WebStorageNamespace* WorkerWebKitClientImpl::createLocalStorageNamespace( return 0; } -WebStorageNamespace* WorkerWebKitClientImpl::createSessionStorageNamespace() { - NOTREACHED(); - return 0; -} - void WorkerWebKitClientImpl::dispatchStorageEvent( const WebString& key, const WebString& old_value, const WebString& new_value, const WebString& origin, diff --git a/chrome/worker/worker_webkitclient_impl.h b/chrome/worker/worker_webkitclient_impl.h index 32ab01d..92299d3 100644 --- a/chrome/worker/worker_webkitclient_impl.h +++ b/chrome/worker/worker_webkitclient_impl.h @@ -31,7 +31,6 @@ class WorkerWebKitClientImpl : public webkit_glue::WebKitClientImpl, virtual WebKit::WebString defaultLocale(); 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/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index de90237..ba13026 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -197,10 +197,6 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { quota); } - virtual WebKit::WebStorageNamespace* createSessionStorageNamespace() { - return WebKit::WebStorageNamespace::createSessionStorageNamespace(); - } - void dispatchStorageEvent(const WebKit::WebString& key, const WebKit::WebString& old_value, const WebKit::WebString& new_value, const WebKit::WebString& origin, const WebKit::WebURL& url, |