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

Side by Side Diff: o3d/gpu_plugin/system_services/shared_memory.cc

Issue 194049: Implemented shared memory as an NPObject. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 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 "o3d/gpu_plugin/system_services/shared_memory.h"
6
7 namespace o3d {
8 namespace gpu_plugin {
9
10 SharedMemory::SharedMemory(NPP npp)
11 : npp_(npp),
12 shared_memory_(NULL) {
Ken Russell (Google) 2009/09/09 01:32:54 Where are the NPObject fields (_class and referenc
apatrick 2009/09/09 02:10:18 Shared memory objects are created through NPN_Crea
13 handle = NULL;
14 ptr = NULL;
15 size = 0;
16 }
17
18 SharedMemory::~SharedMemory() {
19 if (shared_memory_) {
20 delete shared_memory_;
21 }
22 }
23
24 void SharedMemory::Initialize(base::SharedMemory* shared_memory, int32 size) {
25 DCHECK(shared_memory);
26 shared_memory_ = shared_memory;
27 this->handle = shared_memory->handle();
28 this->size = size;
29 }
30
31 bool SharedMemory::Initialize(int32 size) {
32 if (size < 0)
33 return false;
34
35 if (shared_memory_)
36 return false;
37
38 shared_memory_ = new base::SharedMemory();
39 if (!shared_memory_->Create(std::wstring(), false, false, size)) {
40 delete shared_memory_;
41 shared_memory_ = NULL;
42 return false;
43 }
44
45 handle = shared_memory_->handle();
46 this->size = size;
47 return true;
48 }
49
50 bool SharedMemory::Map() {
51 if (!shared_memory_)
52 return false;
53
54 if (!shared_memory_->memory()) {
55 if (!shared_memory_->Map(shared_memory_->max_size()))
56 return false;
57
58 ptr = shared_memory_->memory();
59 }
60
61 return true;
62 }
63
64 } // namespace gpu_plugin
65 } // namespace o3d
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698