OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/renderer/pepper/v8_var_converter.h" | 5 #include "content/renderer/pepper/v8_var_converter.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <stack> | 8 #include <stack> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... | |
40 StackEntry(T v) : val(v), sentinel(false) {} | 40 StackEntry(T v) : val(v), sentinel(false) {} |
41 T val; | 41 T val; |
42 // Used to track parent nodes on the stack while traversing the graph. | 42 // Used to track parent nodes on the stack while traversing the graph. |
43 bool sentinel; | 43 bool sentinel; |
44 }; | 44 }; |
45 | 45 |
46 struct HashedHandle { | 46 struct HashedHandle { |
47 HashedHandle(v8::Handle<v8::Object> h) : handle(h) {} | 47 HashedHandle(v8::Handle<v8::Object> h) : handle(h) {} |
48 size_t hash() const { return handle->GetIdentityHash(); } | 48 size_t hash() const { return handle->GetIdentityHash(); } |
49 bool operator==(const HashedHandle& h) const { return handle == h.handle; } | 49 bool operator==(const HashedHandle& h) const { return handle == h.handle; } |
50 bool operator<(const HashedHandle& h) const { return hash() < h.hash(); } | |
davidben
2014/10/06 23:37:24
I left the other operator<'s in place because it w
| |
51 v8::Handle<v8::Object> handle; | 50 v8::Handle<v8::Object> handle; |
52 }; | 51 }; |
53 | 52 |
54 } // namespace | 53 } // namespace |
55 | 54 |
56 namespace BASE_HASH_NAMESPACE { | 55 namespace BASE_HASH_NAMESPACE { |
57 #if defined(COMPILER_GCC) | |
58 template <> | 56 template <> |
59 struct hash<HashedHandle> { | 57 struct hash<HashedHandle> { |
60 size_t operator()(const HashedHandle& handle) const { return handle.hash(); } | 58 size_t operator()(const HashedHandle& handle) const { return handle.hash(); } |
61 }; | 59 }; |
62 #elif defined(COMPILER_MSVC) | |
63 inline size_t hash_value(const HashedHandle& handle) { return handle.hash(); } | |
64 #endif | |
65 } // namespace BASE_HASH_NAMESPACE | 60 } // namespace BASE_HASH_NAMESPACE |
66 | 61 |
67 namespace content { | 62 namespace content { |
68 | 63 |
69 namespace { | 64 namespace { |
70 | 65 |
71 // Maps PP_Var IDs to the V8 value handle they correspond to. | 66 // Maps PP_Var IDs to the V8 value handle they correspond to. |
72 typedef base::hash_map<int64_t, v8::Handle<v8::Value> > VarHandleMap; | 67 typedef base::hash_map<int64_t, v8::Handle<v8::Value> > VarHandleMap; |
73 typedef base::hash_set<int64_t> ParentVarSet; | 68 typedef base::hash_set<int64_t> ParentVarSet; |
74 | 69 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 std::string(*name_utf8, name_utf8.length()), child_var); | 606 std::string(*name_utf8, name_utf8.length()), child_var); |
612 DCHECK(success); | 607 DCHECK(success); |
613 } | 608 } |
614 } | 609 } |
615 } | 610 } |
616 *result_var = root; | 611 *result_var = root; |
617 return true; | 612 return true; |
618 } | 613 } |
619 | 614 |
620 } // namespace content | 615 } // namespace content |
OLD | NEW |