File tree 3 files changed +40
-0
lines changed
experimental/native_file_system
3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,19 @@ var getDirectoryList = function() {
44
44
extension . internal . sendSyncMessage ( "get" ) ;
45
45
}
46
46
47
+ var getRealPath = function ( virtual_root ) {
48
+ var _msg = {
49
+ cmd : "getRealPath" ,
50
+ path : virtual_root
51
+ }
52
+ return extension . internal . sendSyncMessage ( _msg ) ;
53
+ }
54
+
47
55
NativeFileSystem . prototype = new Object ( ) ;
48
56
NativeFileSystem . prototype . constructor = NativeFileSystem ;
49
57
NativeFileSystem . prototype . requestNativeFileSystem = requestNativeFileSystem ;
50
58
NativeFileSystem . prototype . getDirectoryList = getDirectoryList ;
59
+ NativeFileSystem . prototype . getRealPath = getRealPath ;
51
60
52
61
exports = new NativeFileSystem ( ) ;
53
62
Original file line number Diff line number Diff line change @@ -92,6 +92,36 @@ void NativeFileSystemInstance::HandleMessage(scoped_ptr<base::Value> msg) {
92
92
checker->DoTask ();
93
93
}
94
94
95
+ void NativeFileSystemInstance::HandleSyncMessage (
96
+ scoped_ptr<base::Value> msg) {
97
+ base::DictionaryValue* dict;
98
+ std::string command;
99
+
100
+ if (!msg->GetAsDictionary (&dict) || !dict->GetString (" cmd" , &command)) {
101
+ LOG (ERROR) << " Fail to handle command sync message." ;
102
+ SendSyncReplyToJS (scoped_ptr<base::Value>(new base::StringValue (" " )));
103
+ return ;
104
+ }
105
+
106
+ scoped_ptr<base::Value> result (new base::StringValue (" " ));
107
+ std::string virtual_root_string = " " ;
108
+ if (" getRealPath" == command &&
109
+ dict->GetString (" path" , &virtual_root_string)) {
110
+ std::transform (virtual_root_string.begin (),
111
+ virtual_root_string.end (),
112
+ virtual_root_string.begin (),
113
+ ::toupper);
114
+ std::string real_path =
115
+ VirtualRootProvider::GetInstance ()->GetRealPath (
116
+ virtual_root_string);
117
+ result.reset (new base::StringValue (real_path));
118
+ } else {
119
+ LOG (ERROR) << command << " ASSERT NOT REACHED." ;
120
+ }
121
+
122
+ SendSyncReplyToJS (result.Pass ());
123
+ }
124
+
95
125
FileSystemChecker::FileSystemChecker (
96
126
int process_id,
97
127
const std::string& path,
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ class NativeFileSystemInstance : public XWalkExtensionInstance {
38
38
39
39
// XWalkExtensionInstance implementation.
40
40
virtual void HandleMessage (scoped_ptr<base::Value> msg) OVERRIDE;
41
+ virtual void HandleSyncMessage (scoped_ptr<base::Value> msg) OVERRIDE;
41
42
42
43
private:
43
44
XWalkExtensionFunctionHandler handler_;
You can’t perform that action at this time.
0 commit comments