| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/host_var_tracker.h" | 5 #include "content/renderer/pepper/host_var_tracker.h" |
| 6 | 6 |
| 7 #include <tuple> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "content/renderer/pepper/host_array_buffer_var.h" | 10 #include "content/renderer/pepper/host_array_buffer_var.h" |
| 9 #include "content/renderer/pepper/host_globals.h" | 11 #include "content/renderer/pepper/host_globals.h" |
| 10 #include "content/renderer/pepper/host_resource_var.h" | 12 #include "content/renderer/pepper/host_resource_var.h" |
| 11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 12 #include "content/renderer/pepper/v8object_var.h" | 14 #include "content/renderer/pepper/v8object_var.h" |
| 13 #include "ppapi/c/pp_var.h" | 15 #include "ppapi/c/pp_var.h" |
| 14 | 16 |
| 15 using ppapi::ArrayBufferVar; | 17 using ppapi::ArrayBufferVar; |
| 16 using ppapi::V8ObjectVar; | 18 using ppapi::V8ObjectVar; |
| 17 | 19 |
| 18 namespace content { | 20 namespace content { |
| 19 | 21 |
| 20 HostVarTracker::V8ObjectVarKey::V8ObjectVarKey(V8ObjectVar* object_var) | 22 HostVarTracker::V8ObjectVarKey::V8ObjectVarKey(V8ObjectVar* object_var) |
| 21 : instance(object_var->instance()->pp_instance()) { | 23 : instance(object_var->instance()->pp_instance()) { |
| 22 v8::Local<v8::Object> object = object_var->GetHandle(); | 24 v8::Local<v8::Object> object = object_var->GetHandle(); |
| 23 hash = object.IsEmpty() ? 0 : object->GetIdentityHash(); | 25 hash = object.IsEmpty() ? 0 : object->GetIdentityHash(); |
| 24 } | 26 } |
| 25 | 27 |
| 26 HostVarTracker::V8ObjectVarKey::V8ObjectVarKey(PP_Instance instance, | 28 HostVarTracker::V8ObjectVarKey::V8ObjectVarKey(PP_Instance instance, |
| 27 v8::Local<v8::Object> object) | 29 v8::Local<v8::Object> object) |
| 28 : instance(instance), | 30 : instance(instance), |
| 29 hash(object.IsEmpty() ? 0 : object->GetIdentityHash()) {} | 31 hash(object.IsEmpty() ? 0 : object->GetIdentityHash()) {} |
| 30 | 32 |
| 31 HostVarTracker::V8ObjectVarKey::~V8ObjectVarKey() {} | 33 HostVarTracker::V8ObjectVarKey::~V8ObjectVarKey() {} |
| 32 | 34 |
| 33 bool HostVarTracker::V8ObjectVarKey::operator<( | 35 bool HostVarTracker::V8ObjectVarKey::operator<( |
| 34 const V8ObjectVarKey& other) const { | 36 const V8ObjectVarKey& other) const { |
| 35 if (instance == other.instance) | 37 return std::tie(instance, hash) < std::tie(other.instance, other.hash); |
| 36 return hash < other.hash; | |
| 37 return instance < other.instance; | |
| 38 } | 38 } |
| 39 | 39 |
| 40 HostVarTracker::HostVarTracker() | 40 HostVarTracker::HostVarTracker() |
| 41 : VarTracker(SINGLE_THREADED), last_shared_memory_map_id_(0) {} | 41 : VarTracker(SINGLE_THREADED), last_shared_memory_map_id_(0) {} |
| 42 | 42 |
| 43 HostVarTracker::~HostVarTracker() {} | 43 HostVarTracker::~HostVarTracker() {} |
| 44 | 44 |
| 45 ArrayBufferVar* HostVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { | 45 ArrayBufferVar* HostVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { |
| 46 return new HostArrayBufferVar(size_in_bytes); | 46 return new HostArrayBufferVar(size_in_bytes); |
| 47 } | 47 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 if (it->second.instance != instance) | 180 if (it->second.instance != instance) |
| 181 return false; | 181 return false; |
| 182 | 182 |
| 183 *handle = it->second.handle; | 183 *handle = it->second.handle; |
| 184 *size_in_bytes = it->second.size_in_bytes; | 184 *size_in_bytes = it->second.size_in_bytes; |
| 185 shared_memory_map_.erase(it); | 185 shared_memory_map_.erase(it); |
| 186 return true; | 186 return true; |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace content | 189 } // namespace content |
| OLD | NEW |