| Index: content/browser/dom_storage/dom_storage_message_filter_new.h
|
| ===================================================================
|
| --- content/browser/dom_storage/dom_storage_message_filter_new.h (revision 0)
|
| +++ content/browser/dom_storage/dom_storage_message_filter_new.h (working copy)
|
| @@ -2,49 +2,51 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_MESSAGE_FILTER_H_
|
| -#define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_MESSAGE_FILTER_H_
|
| +#ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_MESSAGE_FILTER_H_
|
| +#define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_MESSAGE_FILTER_H_
|
| #pragma once
|
|
|
| #include "base/memory/ref_counted.h"
|
| -#include "base/message_loop_helpers.h"
|
| -#include "base/process.h"
|
| -#include "content/browser/in_process_webkit/dom_storage_area.h"
|
| -#include "content/common/dom_storage_common.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "content/public/browser/browser_message_filter.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
|
| +#include "webkit/dom_storage/dom_storage_context.h"
|
| +#include "webkit/dom_storage/dom_storage_types.h"
|
|
|
| +#ifdef ENABLE_NEW_DOM_STORAGE_BACKEND
|
| +
|
| class DOMStorageContextImpl;
|
| class GURL;
|
| -struct DOMStorageMsg_Event_Params;
|
| +class NullableString16;
|
|
|
| +namespace dom_storage {
|
| +class DomStorageArea;
|
| +class DomStorageContext;
|
| +class DomStorageHost;
|
| +}
|
| +
|
| // This class handles the logistics of DOM Storage within the browser process.
|
| -// It mostly ferries information between IPCs and the WebKit implementations,
|
| -// but it also handles some special cases like when renderer processes die.
|
| -class DOMStorageMessageFilter : public content::BrowserMessageFilter {
|
| +// It mostly ferries information between IPCs and the dom_storage classes.
|
| +class DOMStorageMessageFilter
|
| + : public content::BrowserMessageFilter,
|
| + public dom_storage::DomStorageContext::EventObserver {
|
| public:
|
| - // Only call the constructor from the UI thread.
|
| - DOMStorageMessageFilter(int process_id,
|
| - DOMStorageContextImpl* dom_storage_context);
|
| + explicit DOMStorageMessageFilter(int unused, DOMStorageContextImpl* context);
|
|
|
| + private:
|
| + virtual ~DOMStorageMessageFilter();
|
| +
|
| + void InitializeInSequence();
|
| + void UninitializeInSequence();
|
| +
|
| // content::BrowserMessageFilter implementation
|
| - virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
|
| - virtual void OverrideThreadForMessage(
|
| - const IPC::Message& message,
|
| - content::BrowserThread::ID* thread) OVERRIDE;
|
| + virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
|
| + virtual void OnFilterRemoved() OVERRIDE;
|
| + virtual base::TaskRunner* OverrideTaskRunnerForMessage(
|
| + const IPC::Message& message) OVERRIDE;
|
| virtual bool OnMessageReceived(const IPC::Message& message,
|
| bool* message_was_ok) OVERRIDE;
|
| - virtual void OnDestruct() const OVERRIDE;
|
|
|
| - // Only call on the WebKit thread.
|
| - static void DispatchStorageEvent(const NullableString16& key,
|
| - const NullableString16& old_value, const NullableString16& new_value,
|
| - const string16& origin, const GURL& url, bool is_local_storage);
|
| -
|
| - private:
|
| - friend class content::BrowserThread;
|
| - friend class base::DeleteHelper<DOMStorageMessageFilter>;
|
| - virtual ~DOMStorageMessageFilter();
|
| -
|
| // Message Handlers.
|
| void OnOpenStorageArea(int64 namespace_id, const string16& origin,
|
| int64* storage_area_id);
|
| @@ -61,31 +63,37 @@
|
| const GURL& url, NullableString16* old_value);
|
| void OnClear(int64 storage_area_id, const GURL& url, bool* something_cleared);
|
|
|
| - // Only call on the IO thread.
|
| - void OnStorageEvent(const DOMStorageMsg_Event_Params& params);
|
| + // DomStorageContext::EventObserver implementation which
|
| + // sends events back to our renderer process.
|
| + virtual void OnDomStorageItemSet(
|
| + const dom_storage::DomStorageArea* area,
|
| + const string16& key,
|
| + const string16& new_value,
|
| + const NullableString16& old_value,
|
| + const GURL& page_url) OVERRIDE;
|
| + virtual void OnDomStorageItemRemoved(
|
| + const dom_storage::DomStorageArea* area,
|
| + const string16& key,
|
| + const string16& old_value,
|
| + const GURL& page_url) OVERRIDE;
|
| + virtual void OnDomStorageAreaCleared(
|
| + const dom_storage::DomStorageArea* area,
|
| + const GURL& page_url) OVERRIDE;
|
|
|
| - // A shortcut for accessing our context.
|
| - DOMStorageContextImpl* Context() { return dom_storage_context_; }
|
| + void SendDomStorageEvent(
|
| + const dom_storage::DomStorageArea* area,
|
| + const GURL& page_url,
|
| + const NullableString16& key,
|
| + const NullableString16& new_value,
|
| + const NullableString16& old_value);
|
|
|
| - // Use whenever there's a chance OnStorageEvent will be called.
|
| - class ScopedStorageEventContext {
|
| - public:
|
| - ScopedStorageEventContext(
|
| - DOMStorageMessageFilter* dispatcher_message_filter,
|
| - const GURL* url);
|
| - ~ScopedStorageEventContext();
|
| - };
|
| + scoped_refptr<dom_storage::DomStorageContext> context_;
|
| + scoped_ptr<dom_storage::DomStorageHost> host_;
|
| + bool is_dispatching_message_;
|
|
|
| - // Only access on the WebKit thread! Used for storage events.
|
| - static DOMStorageMessageFilter* storage_event_message_filter;
|
| - static const GURL* storage_event_url_;
|
| -
|
| - scoped_refptr<DOMStorageContextImpl> dom_storage_context_;
|
| -
|
| - // Used to dispatch messages to the correct view host.
|
| - int process_id_;
|
| -
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageMessageFilter);
|
| };
|
|
|
| -#endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_MESSAGE_FILTER_H_
|
| +#endif // ENABLE_NEW_DOM_STORAGE_BACKEND
|
| +
|
| +#endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_MESSAGE_FILTER_H_
|
|
|