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

Side by Side Diff: ppapi/proxy/raw_var_data.cc

Issue 1548813002: Switch to standard integer types in ppapi/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years 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
« no previous file with comments | « ppapi/proxy/raw_var_data.h ('k') | ppapi/proxy/raw_var_data_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ppapi/proxy/raw_var_data.h" 5 #include "ppapi/proxy/raw_var_data.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 10 matching lines...) Expand all
21 using std::make_pair; 21 using std::make_pair;
22 22
23 namespace ppapi { 23 namespace ppapi {
24 namespace proxy { 24 namespace proxy {
25 25
26 namespace { 26 namespace {
27 27
28 // When sending array buffers, if the size is over 256K, we use shared 28 // When sending array buffers, if the size is over 256K, we use shared
29 // memory instead of sending the data over IPC. Light testing suggests 29 // memory instead of sending the data over IPC. Light testing suggests
30 // shared memory is much faster for 256K and larger messages. 30 // shared memory is much faster for 256K and larger messages.
31 static const uint32 kMinimumArrayBufferSizeForShmem = 256 * 1024; 31 static const uint32_t kMinimumArrayBufferSizeForShmem = 256 * 1024;
32 static uint32 g_minimum_array_buffer_size_for_shmem = 32 static uint32_t g_minimum_array_buffer_size_for_shmem =
33 kMinimumArrayBufferSizeForShmem; 33 kMinimumArrayBufferSizeForShmem;
34 34
35 struct StackEntry { 35 struct StackEntry {
36 StackEntry(PP_Var v, size_t i) : var(v), data_index(i) {} 36 StackEntry(PP_Var v, size_t i) : var(v), data_index(i) {}
37 PP_Var var; 37 PP_Var var;
38 size_t data_index; 38 size_t data_index;
39 }; 39 };
40 40
41 // For a given PP_Var, returns the RawVarData associated with it, or creates a 41 // For a given PP_Var, returns the RawVarData associated with it, or creates a
42 // new one if there is no existing one. The data is appended to |data| if it 42 // new one if there is no existing one. The data is appended to |data| if it
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 for (size_t i = 0; i < data_.size(); ++i) { 207 for (size_t i = 0; i < data_.size(); ++i) {
208 SerializedHandle* handle = data_[i]->GetHandle(); 208 SerializedHandle* handle = data_[i]->GetHandle();
209 if (handle) 209 if (handle)
210 result.push_back(handle); 210 result.push_back(handle);
211 } 211 }
212 return result; 212 return result;
213 } 213 }
214 214
215 // static 215 // static
216 void RawVarDataGraph::SetMinimumArrayBufferSizeForShmemForTest( 216 void RawVarDataGraph::SetMinimumArrayBufferSizeForShmemForTest(
217 uint32 threshold) { 217 uint32_t threshold) {
218 if (threshold == 0) 218 if (threshold == 0)
219 g_minimum_array_buffer_size_for_shmem = kMinimumArrayBufferSizeForShmem; 219 g_minimum_array_buffer_size_for_shmem = kMinimumArrayBufferSizeForShmem;
220 else 220 else
221 g_minimum_array_buffer_size_for_shmem = threshold; 221 g_minimum_array_buffer_size_for_shmem = threshold;
222 } 222 }
223 223
224 // RawVarData ------------------------------------------------------------------ 224 // RawVarData ------------------------------------------------------------------
225 225
226 // static 226 // static
227 RawVarData* RawVarData::Create(PP_VarType type) { 227 RawVarData* RawVarData::Create(PP_VarType type) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 437 }
438 initialized_ = true; 438 initialized_ = true;
439 return true; 439 return true;
440 } 440 }
441 441
442 PP_Var ArrayBufferRawVarData::CreatePPVar(PP_Instance instance) { 442 PP_Var ArrayBufferRawVarData::CreatePPVar(PP_Instance instance) {
443 PP_Var result = PP_MakeUndefined(); 443 PP_Var result = PP_MakeUndefined();
444 switch (type_) { 444 switch (type_) {
445 case ARRAY_BUFFER_SHMEM_HOST: { 445 case ARRAY_BUFFER_SHMEM_HOST: {
446 base::SharedMemoryHandle host_handle; 446 base::SharedMemoryHandle host_handle;
447 uint32 size_in_bytes; 447 uint32_t size_in_bytes;
448 bool ok = PpapiGlobals::Get()->GetVarTracker()-> 448 bool ok = PpapiGlobals::Get()->GetVarTracker()->
449 StopTrackingSharedMemoryHandle(host_shm_handle_id_, 449 StopTrackingSharedMemoryHandle(host_shm_handle_id_,
450 instance, 450 instance,
451 &host_handle, 451 &host_handle,
452 &size_in_bytes); 452 &size_in_bytes);
453 if (ok) { 453 if (ok) {
454 result = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 454 result = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
455 size_in_bytes, host_handle); 455 size_in_bytes, host_handle);
456 } else { 456 } else {
457 LOG(ERROR) << "Couldn't find array buffer id: " << host_shm_handle_id_; 457 LOG(ERROR) << "Couldn't find array buffer id: " << host_shm_handle_id_;
458 return PP_MakeUndefined(); 458 return PP_MakeUndefined();
459 } 459 }
460 break; 460 break;
461 } 461 }
462 case ARRAY_BUFFER_SHMEM_PLUGIN: { 462 case ARRAY_BUFFER_SHMEM_PLUGIN: {
463 result = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 463 result = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
464 plugin_shm_handle_.size(), 464 plugin_shm_handle_.size(),
465 plugin_shm_handle_.shmem()); 465 plugin_shm_handle_.shmem());
466 break; 466 break;
467 } 467 }
468 case ARRAY_BUFFER_NO_SHMEM: { 468 case ARRAY_BUFFER_NO_SHMEM: {
469 result = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 469 result = PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
470 static_cast<uint32>(data_.size()), data_.data()); 470 static_cast<uint32_t>(data_.size()), data_.data());
471 break; 471 break;
472 } 472 }
473 default: 473 default:
474 NOTREACHED(); 474 NOTREACHED();
475 return PP_MakeUndefined(); 475 return PP_MakeUndefined();
476 } 476 }
477 DCHECK(result.type == PP_VARTYPE_ARRAY_BUFFER); 477 DCHECK(result.type == PP_VARTYPE_ARRAY_BUFFER);
478 return result; 478 return result;
479 } 479 }
480 480
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 if (!IPC::ReadParam(m, iter, creation_message_.get())) 741 if (!IPC::ReadParam(m, iter, creation_message_.get()))
742 return false; 742 return false;
743 } else { 743 } else {
744 creation_message_.reset(); 744 creation_message_.reset();
745 } 745 }
746 return true; 746 return true;
747 } 747 }
748 748
749 } // namespace proxy 749 } // namespace proxy
750 } // namespace ppapi 750 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/raw_var_data.h ('k') | ppapi/proxy/raw_var_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698