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

Side by Side Diff: runtime/embedders/openglui/emulator/emulator_resource.h

Issue 25081002: Remove openglui embedder code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef EMBEDDERS_OPENGLUI_EMULATOR_EMULATOR_RESOURCE_H_
6 #define EMBEDDERS_OPENGLUI_EMULATOR_EMULATOR_RESOURCE_H_
7
8 #include <fcntl.h>
9 #include <sys/stat.h>
10 #include <sys/types.h>
11 #include <unistd.h>
12
13 #include "embedders/openglui/common/log.h"
14 #include "embedders/openglui/common/resource.h"
15
16 class EmulatorResource : public Resource {
17 public:
18 explicit EmulatorResource(const char* path)
19 : Resource(path),
20 fd_(-1) {
21 }
22
23 int32_t descriptor() {
24 if (fd_ < 0) {
25 Open();
26 }
27 return fd_;
28 }
29
30 off_t length() {
31 if (length_ < 0) {
32 length_ = lseek(fd_, 0, SEEK_END);
33 lseek(fd_, 0, SEEK_SET);
34 }
35 return length_;
36 }
37
38 int32_t Open() {
39 fd_ = open(path_, 0);
40 if (fd_ >= 0) {
41 return 0;
42 }
43 LOGE("Could not open asset %s", path_);
44 return -1;
45 }
46
47 void Close() {
48 if (fd_ >= 0) {
49 close(fd_);
50 fd_ = -1;
51 }
52 }
53
54 int32_t Read(void* buffer, size_t count) {
55 size_t actual = read(fd_, buffer, count);
56 return (actual == count) ? 0 : -1;
57 }
58
59 private:
60 int fd_;
61 };
62
63 #endif // EMBEDDERS_OPENGLUI_EMULATOR_EMULATOR_RESOURCE_H_
64
OLDNEW
« no previous file with comments | « runtime/embedders/openglui/emulator/emulator_graphics_handler.cc ('k') | runtime/embedders/openglui/openglui_embedder.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698