Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: media/blink/multibuffer.h

Issue 1502373009: Allow std::unordered_*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, more HashPair -> HashInts Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BLINK_MULTIBUFFER_H_ 5 #ifndef MEDIA_BLINK_MULTIBUFFER_H_
6 #define MEDIA_BLINK_MULTIBUFFER_H_ 6 #define MEDIA_BLINK_MULTIBUFFER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <limits> 11 #include <limits>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/containers/hash_tables.h" 17 #include "base/containers/hash_tables.h"
18 #include "base/hash.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "media/base/data_buffer.h" 23 #include "media/base/data_buffer.h"
23 #include "media/blink/interval_map.h" 24 #include "media/blink/interval_map.h"
24 #include "media/blink/lru.h" 25 #include "media/blink/lru.h"
25 #include "media/blink/media_blink_export.h" 26 #include "media/blink/media_blink_export.h"
26 27
27 namespace media { 28 namespace media {
28 29
29 // Used to identify a block of data in the multibuffer. 30 // Used to identify a block of data in the multibuffer.
30 // Our blocks are 32kb (1 << 15), so our maximum cacheable file size 31 // Our blocks are 32kb (1 << 15), so our maximum cacheable file size
31 // is 1 << (15 + 31) = 64Tb 32 // is 1 << (15 + 31) = 64Tb
32 typedef int32_t MultiBufferBlockId; 33 typedef int32_t MultiBufferBlockId;
33 class MultiBuffer; 34 class MultiBuffer;
34 35
35 // This type is used to identify a block in the LRU, which is shared between 36 // This type is used to identify a block in the LRU, which is shared between
36 // multibuffers. 37 // multibuffers.
37 typedef std::pair<MultiBuffer*, MultiBufferBlockId> MultiBufferGlobalBlockId; 38 typedef std::pair<MultiBuffer*, MultiBufferBlockId> MultiBufferGlobalBlockId;
38 39
39 } // namespace media 40 } // namespace media
40 41
41 namespace BASE_HASH_NAMESPACE { 42 namespace BASE_HASH_NAMESPACE {
42 43
43 template <> 44 template <>
44 struct hash<media::MultiBufferGlobalBlockId> { 45 struct hash<media::MultiBufferGlobalBlockId> {
45 std::size_t operator()(const media::MultiBufferGlobalBlockId& key) const { 46 std::size_t operator()(const media::MultiBufferGlobalBlockId& key) const {
46 // It would be nice if we could use intptr_t instead of int64_t here, but 47 return base::HashInts(reinterpret_cast<uintptr_t>(key.first), key.second);
47 // on some platforms, int64_t is declared as "long" which doesn't match
48 // any of the HashPair() functions. This leads to a compile error since
49 // the compiler can't decide which HashPair() function to call.
50 #if defined(ARCH_CPU_64_BITS)
51 return base::HashPair(reinterpret_cast<int64_t>(key.first), key.second);
52 #else
53 return base::HashPair(reinterpret_cast<int32_t>(key.first), key.second);
54 #endif
55 } 48 }
56 }; 49 };
57 50
58 } // namespace BASE_HASH_NAMESPACE 51 } // namespace BASE_HASH_NAMESPACE
59 52
60 namespace media { 53 namespace media {
61 54
62 // Freeing a lot of blocks can be expensive, to keep thing 55 // Freeing a lot of blocks can be expensive, to keep thing
63 // flowing smoothly we only free a maximum of |kMaxFreesPerAdd| 56 // flowing smoothly we only free a maximum of |kMaxFreesPerAdd|
64 // blocks when a new block is added to the cache. 57 // blocks when a new block is added to the cache.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // and 0 for all blocks that are not. Used to quickly figure out 311 // and 0 for all blocks that are not. Used to quickly figure out
319 // ranges of available/unavailable blocks without iterating. 312 // ranges of available/unavailable blocks without iterating.
320 IntervalMap<BlockId, int32_t> present_; 313 IntervalMap<BlockId, int32_t> present_;
321 314
322 DISALLOW_COPY_AND_ASSIGN(MultiBuffer); 315 DISALLOW_COPY_AND_ASSIGN(MultiBuffer);
323 }; 316 };
324 317
325 } // namespace media 318 } // namespace media
326 319
327 #endif // MEDIA_BLINK_MULTIBUFFER_H_ 320 #endif // MEDIA_BLINK_MULTIBUFFER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_completeness_cache.h ('k') | net/base/network_change_notifier_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698