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

Side by Side Diff: gin/test/file.cc

Issue 1112923003: Replace Handle<> with Local in remaining gin/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « gin/shell_runner.cc ('k') | gin/test/file_runner.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gin/test/file.h" 5 #include "gin/test/file.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "gin/arguments.h" 14 #include "gin/arguments.h"
15 #include "gin/converter.h" 15 #include "gin/converter.h"
16 #include "gin/object_template_builder.h" 16 #include "gin/object_template_builder.h"
17 #include "gin/per_isolate_data.h" 17 #include "gin/per_isolate_data.h"
18 #include "gin/public/wrapper_info.h" 18 #include "gin/public/wrapper_info.h"
19 19
20 using v8::ObjectTemplate; 20 using v8::ObjectTemplate;
21 21
22 namespace gin { 22 namespace gin {
23 23
24 namespace { 24 namespace {
25 25
26 v8::Handle<v8::Value> ReadFileToString(gin::Arguments* args) { 26 v8::Local<v8::Value> ReadFileToString(gin::Arguments* args) {
27 std::string filename; 27 std::string filename;
28 if (!args->GetNext(&filename)) 28 if (!args->GetNext(&filename))
29 return v8::Null(args->isolate()); 29 return v8::Null(args->isolate());
30 30
31 const base::FilePath& path = base::FilePath::FromUTF8Unsafe(filename); 31 const base::FilePath& path = base::FilePath::FromUTF8Unsafe(filename);
32 std::string contents; 32 std::string contents;
33 if (!ReadFileToString(path, &contents)) 33 if (!ReadFileToString(path, &contents))
34 return v8::Null(args->isolate()); 34 return v8::Null(args->isolate());
35 35
36 return gin::Converter<std::string>::ToV8(args->isolate(), contents); 36 return gin::Converter<std::string>::ToV8(args->isolate(), contents);
37 } 37 }
38 38
39 v8::Handle<v8::Value> GetSourceRootDirectory(gin::Arguments* args) { 39 v8::Local<v8::Value> GetSourceRootDirectory(gin::Arguments* args) {
40 base::FilePath path; 40 base::FilePath path;
41 if (!PathService::Get(base::DIR_SOURCE_ROOT, &path)) 41 if (!PathService::Get(base::DIR_SOURCE_ROOT, &path))
42 return v8::Null(args->isolate()); 42 return v8::Null(args->isolate());
43 return gin::Converter<std::string>::ToV8(args->isolate(), 43 return gin::Converter<std::string>::ToV8(args->isolate(),
44 path.AsUTF8Unsafe()); 44 path.AsUTF8Unsafe());
45 } 45 }
46 46
47 v8::Handle<v8::Value> GetFilesInDirectory(gin::Arguments* args) { 47 v8::Local<v8::Value> GetFilesInDirectory(gin::Arguments* args) {
48 std::string filename; 48 std::string filename;
49 if (!args->GetNext(&filename)) 49 if (!args->GetNext(&filename))
50 return v8::Null(args->isolate()); 50 return v8::Null(args->isolate());
51 51
52 const base::FilePath& path = base::FilePath::FromUTF8Unsafe(filename); 52 const base::FilePath& path = base::FilePath::FromUTF8Unsafe(filename);
53 if (!base::DirectoryExists(path)) 53 if (!base::DirectoryExists(path))
54 return v8::Null(args->isolate()); 54 return v8::Null(args->isolate());
55 55
56 std::vector<std::string> names; 56 std::vector<std::string> names;
57 base::FileEnumerator e(path, false, base::FileEnumerator::FILES); 57 base::FileEnumerator e(path, false, base::FileEnumerator::FILES);
(...skipping 19 matching lines...) Expand all
77 .SetMethod("readFileToString", ReadFileToString) 77 .SetMethod("readFileToString", ReadFileToString)
78 .SetMethod("getFilesInDirectory", GetFilesInDirectory) 78 .SetMethod("getFilesInDirectory", GetFilesInDirectory)
79 .SetMethod("getSourceRootDirectory", GetSourceRootDirectory) 79 .SetMethod("getSourceRootDirectory", GetSourceRootDirectory)
80 .Build(); 80 .Build();
81 data->SetObjectTemplate(&g_wrapper_info, templ); 81 data->SetObjectTemplate(&g_wrapper_info, templ);
82 } 82 }
83 return templ->NewInstance(); 83 return templ->NewInstance();
84 } 84 }
85 85
86 } // namespace gin 86 } // namespace gin
OLDNEW
« no previous file with comments | « gin/shell_runner.cc ('k') | gin/test/file_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698