ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / content / common / host_shared_bitmap_manager.h
blob423023abc28f702146fde7d773adb7c8f9204777
1 // Copyright (c) 2013 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.
5 #ifndef CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
6 #define CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
8 #include <map>
9 #include <set>
11 #include "base/basictypes.h"
12 #include "base/containers/hash_tables.h"
13 #include "base/hash.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/shared_memory.h"
17 #include "base/synchronization/lock.h"
18 #include "cc/resources/shared_bitmap_manager.h"
19 #include "content/common/content_export.h"
21 namespace BASE_HASH_NAMESPACE {
22 template <>
23 struct hash<cc::SharedBitmapId> {
24 size_t operator()(const cc::SharedBitmapId& id) const {
25 return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name));
28 } // namespace BASE_HASH_NAMESPACE
30 namespace content {
31 class BitmapData;
33 class CONTENT_EXPORT HostSharedBitmapManager : public cc::SharedBitmapManager {
34 public:
35 HostSharedBitmapManager();
36 ~HostSharedBitmapManager() override;
38 static HostSharedBitmapManager* current();
40 // cc::SharedBitmapManager implementation.
41 scoped_ptr<cc::SharedBitmap> AllocateSharedBitmap(
42 const gfx::Size& size) override;
43 scoped_ptr<cc::SharedBitmap> GetSharedBitmapFromId(
44 const gfx::Size& size,
45 const cc::SharedBitmapId&) override;
47 void AllocateSharedBitmapForChild(
48 base::ProcessHandle process_handle,
49 size_t buffer_size,
50 const cc::SharedBitmapId& id,
51 base::SharedMemoryHandle* shared_memory_handle);
52 void ChildAllocatedSharedBitmap(size_t buffer_size,
53 const base::SharedMemoryHandle& handle,
54 base::ProcessHandle process_handle,
55 const cc::SharedBitmapId& id);
56 void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
57 void ProcessRemoved(base::ProcessHandle process_handle);
59 size_t AllocatedBitmapCount() const;
61 void FreeSharedMemoryFromMap(const cc::SharedBitmapId& id);
63 private:
64 mutable base::Lock lock_;
66 typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> >
67 BitmapMap;
68 BitmapMap handle_map_;
70 typedef base::hash_map<base::ProcessHandle,
71 base::hash_set<cc::SharedBitmapId> > ProcessMap;
72 ProcessMap process_map_;
75 } // namespace content
77 #endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_