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

Side by Side Diff: ppapi/shared_impl/vpn_provider_util.cc

Issue 1931513002: ppapi: PPB_VpnProvider: Implement Resource Stub (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vpn-api-messages
Patch Set: Respond to review. Created 4 years, 7 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
(Empty)
1 // Copyright 2016 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.
4
5 #include "ppapi/shared_impl/vpn_provider_util.h"
6
7 namespace ppapi {
8
9 VpnProviderSharedBuffer::VpnProviderSharedBuffer(
10 uint32_t capacity,
11 uint32_t packet_size,
12 std::unique_ptr<base::SharedMemory> shm)
13 : capacity_(capacity),
14 packet_size_(packet_size),
15 shm_(std::move(shm)),
16 available_(capacity, true) {
17 DCHECK(this->shm_);
18 }
19
20 VpnProviderSharedBuffer::~VpnProviderSharedBuffer() {}
21
22 bool VpnProviderSharedBuffer::GetAvailable(uint32_t* id) {
23 for (uint32_t it = 0; it < capacity_; it++) {
bbudge 2016/05/17 13:34:39 nit: s/it/i since you're indexing, it seems cleare
adrian.belgun 2016/05/17 15:25:29 Done.
24 if (available_[it]) {
25 if (id) {
26 *id = it;
27 }
28 return true;
29 }
30 }
31 return false;
32 }
33
34 void VpnProviderSharedBuffer::SetAvailable(uint32_t id, bool value) {
35 if (id >= capacity_) {
36 NOTREACHED();
37 return;
38 }
39 available_[id] = value;
40 }
41
42 void* VpnProviderSharedBuffer::GetBuffer(uint32_t id) {
43 if (id >= capacity_) {
44 NOTREACHED();
45 return nullptr;
46 }
47 return (void*)((char*)(shm_->memory()) + packet_size_ * id);
bbudge 2016/05/17 13:34:39 c++-style casts for chromium code.
adrian.belgun 2016/05/17 15:25:29 Done.
48 }
49
50 base::SharedMemoryHandle VpnProviderSharedBuffer::GetHandle() {
51 return shm_->handle();
52 }
53
54 } // namespace ppapi
OLDNEW
« ppapi/proxy/ppapi_messages.h ('K') | « ppapi/shared_impl/vpn_provider_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698