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

Side by Side Diff: runtime/embedders/android/resource.h

Issue 11467028: Migrate files to embedder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review fixes Created 7 years, 11 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
« no previous file with comments | « runtime/embedders/android/main.cc ('k') | runtime/embedders/android/sound_service.h » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RESOURCE_H 5 #ifndef EMBEDDERS_ANDROID_RESOURCE_H_
6 #define RESOURCE_H 6 #define EMBEDDERS_ANDROID_RESOURCE_H_
7 7
8 #include <android_native_app_glue.h> 8 #include <android_native_app_glue.h>
9 9
10 #include "jni/log.h" 10 #include "embedders/android/log.h"
11 11
12 class Resource { 12 class Resource {
13 public: 13 public:
14 Resource(android_app* application, const char* path) 14 Resource(android_app* application, const char* path)
15 : asset_manager_(application->activity->assetManager), 15 : asset_manager_(application->activity->assetManager),
16 path_(path), 16 path_(path),
17 asset_(NULL), 17 asset_(NULL),
18 descriptor_(-1), 18 descriptor_(-1),
19 start_(0), 19 start_(0),
20 length_(0) { 20 length_(0) {
(...skipping 13 matching lines...) Expand all
34 34
35 off_t length() { 35 off_t length() {
36 return length_; 36 return length_;
37 } 37 }
38 38
39 int32_t open() { 39 int32_t open() {
40 asset_ = AAssetManager_open(asset_manager_, path_, AASSET_MODE_UNKNOWN); 40 asset_ = AAssetManager_open(asset_manager_, path_, AASSET_MODE_UNKNOWN);
41 if (asset_ != NULL) { 41 if (asset_ != NULL) {
42 descriptor_ = AAsset_openFileDescriptor(asset_, &start_, &length_); 42 descriptor_ = AAsset_openFileDescriptor(asset_, &start_, &length_);
43 LOGI("%s has start %d, length %d, fd %d", 43 LOGI("%s has start %d, length %d, fd %d",
44 path_, start_, length_, descriptor_); 44 path_, static_cast<int>(start_),
45 static_cast<int>(length_), descriptor_);
45 return 0; 46 return 0;
46 } 47 }
47 return -1; 48 return -1;
48 } 49 }
49 50
50 void close() { 51 void close() {
51 if (asset_ != NULL) { 52 if (asset_ != NULL) {
52 AAsset_close(asset_); 53 AAsset_close(asset_);
53 asset_ = NULL; 54 asset_ = NULL;
54 } 55 }
55 } 56 }
56 57
57 int32_t read(void* buffer, size_t count) { 58 int32_t read(void* buffer, size_t count) {
58 int32_t actual = AAsset_read(asset_, buffer, count); 59 size_t actual = AAsset_read(asset_, buffer, count);
59 return (actual == count) ? 0 : -1; 60 return (actual == count) ? 0 : -1;
60 } 61 }
61 62
62 private: 63 private:
64 AAssetManager* asset_manager_;
63 const char* path_; 65 const char* path_;
64 AAssetManager* asset_manager_;
65 AAsset* asset_; 66 AAsset* asset_;
66 int32_t descriptor_; 67 int32_t descriptor_;
67 off_t start_; 68 off_t start_;
68 off_t length_; 69 off_t length_;
69 }; 70 };
70 71
71 #endif 72 #endif // EMBEDDERS_ANDROID_RESOURCE_H_
OLDNEW
« no previous file with comments | « runtime/embedders/android/main.cc ('k') | runtime/embedders/android/sound_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698