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

Side by Side Diff: chrome/common/transport_dib_mac.cc

Issue 21485: Bitmap transport (Closed)
Patch Set: Fix some mac crashes Created 11 years, 10 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 (c) 2009 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 "chrome/common/transport_dib.h"
6
7 #include <unistd.h>
8 #include <sys/stat.h>
9 #include "base/shared_memory.h"
10
11 TransportDIB::TransportDIB()
12 : size_(0) {
13 }
14
15 TransportDIB::TransportDIB(TransportDIB::Handle dib)
16 : shared_memory_(dib, false /* read write */),
17 size_(0) {
18 }
19
20 TransportDIB::~TransportDIB() {
21 }
22
23 // static
24 TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) {
25 TransportDIB* dib = new TransportDIB;
26 if (!dib->shared_memory_.Create(L"", false /* read write */,
27 false /* do not open existing */, size)) {
28 delete dib;
29 return NULL;
30 }
31
32 dib->size_ = size;
33 return dib;
34 }
35
36 // static
37 TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) {
38 TransportDIB* dib = new TransportDIB(handle);
39 struct stat st;
40 fstat(handle.fd, &st);
41
42 if (!dib->shared_memory_.Map(st.st_size)) {
43 delete dib;
44 close(handle.fd);
45 return false;
46 }
47
48 dib->size_ = st.st_size;
49
50 return dib;
51 }
52
53 void* TransportDIB::memory() const {
54 return shared_memory_.memory();
55 }
56
57 TransportDIB::Id TransportDIB::id() const {
58 return false;
59 }
60
61 TransportDIB::Handle TransportDIB::handle() const {
62 return shared_memory_.handle();
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698