1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_DISPATCHER_H_ 6 #define CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_DISPATCHER_H_ 7 8 #include "base/memory/ref_counted.h" 9 10 class GURL; 11 struct DOMStorageMsg_Event_Params; 12 13 namespace IPC { 14 class Message; 15 } 16 17 namespace content { 18 19 class DOMStorageCachedArea; 20 21 // Dispatches DomStorage related messages sent to a renderer process from the 22 // main browser process. There is one instance per child process. Messages 23 // are dispatched on the main renderer thread. The RenderThreadImpl 24 // creates an instance and delegates calls to it. This classes also manages 25 // the collection of DOMStorageCachedAreas that are active in the process. 26 class DomStorageDispatcher { 27 public: 28 DomStorageDispatcher(); 29 ~DomStorageDispatcher(); 30 31 // Each call to open should be balanced with a call to close. 32 scoped_refptr<DOMStorageCachedArea> OpenCachedArea(int connection_id, 33 int64 namespace_id, 34 const GURL& origin); 35 void CloseCachedArea(int connection_id, DOMStorageCachedArea* area); 36 37 bool OnMessageReceived(const IPC::Message& msg); 38 39 private: 40 class ProxyImpl; 41 42 // IPC message handlers 43 void OnStorageEvent(const DOMStorageMsg_Event_Params& params); 44 void OnAsyncOperationComplete(bool success); 45 void OnResetCachedValues(int64 namespace_id); 46 47 scoped_refptr<ProxyImpl> proxy_; 48 }; 49 50 } // namespace content 51 52 #endif // CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_DISPATCHER_H_ 53