summaryrefslogtreecommitdiffstats
path: root/content/renderer/dom_storage/dom_storage_dispatcher.h
blob: 0ff96447b59ed7f0c6d9236e788a411b7b34f841 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2012 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 CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_DISPATCHER_H_
#define CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_DISPATCHER_H_

#include <stdint.h>

#include "base/memory/ref_counted.h"

class GURL;
struct DOMStorageMsg_Event_Params;

namespace IPC {
class Message;
}

namespace content {

class DOMStorageCachedArea;

// Dispatches DomStorage related messages sent to a renderer process from the
// main browser process. There is one instance per child process. Messages
// are dispatched on the main renderer thread. The RenderThreadImpl
// creates an instance and delegates calls to it. This classes also manages
// the collection of DOMStorageCachedAreas that are active in the process.
class DomStorageDispatcher {
 public:
  DomStorageDispatcher();
  ~DomStorageDispatcher();

  // Each call to open should be balanced with a call to close.
  scoped_refptr<DOMStorageCachedArea> OpenCachedArea(int connection_id,
                                                     int64_t namespace_id,
                                                     const GURL& origin);
  void CloseCachedArea(int connection_id, DOMStorageCachedArea* area);

  bool OnMessageReceived(const IPC::Message& msg);

 private:
  class ProxyImpl;

  // IPC message handlers
  void OnStorageEvent(const DOMStorageMsg_Event_Params& params);
  void OnAsyncOperationComplete(bool success);

  scoped_refptr<ProxyImpl> proxy_;
};

}  // namespace content

#endif  // CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_DISPATCHER_H_