OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/drive/file_system_core_util.h" | 5 #include "components/drive/file_system_core_util.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <string> | 10 #include <string> |
8 #include <vector> | 11 #include <vector> |
9 | 12 |
10 #include "base/basictypes.h" | |
11 #include "base/bind.h" | 13 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
13 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
15 #include "base/i18n/icu_string_conversions.h" | 17 #include "base/i18n/icu_string_conversions.h" |
16 #include "base/json/json_file_value_serializer.h" | 18 #include "base/json/json_file_value_serializer.h" |
17 #include "base/logging.h" | 19 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
19 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
20 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
23 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
24 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
25 #include "components/drive/drive.pb.h" | 27 #include "components/drive/drive.pb.h" |
26 #include "components/drive/drive_pref_names.h" | 28 #include "components/drive/drive_pref_names.h" |
27 #include "components/drive/job_list.h" | 29 #include "components/drive/job_list.h" |
28 | 30 |
29 namespace drive { | 31 namespace drive { |
30 namespace util { | 32 namespace util { |
31 | 33 |
32 namespace { | 34 namespace { |
33 | 35 |
34 std::string ReadStringFromGDocFile(const base::FilePath& file_path, | 36 std::string ReadStringFromGDocFile(const base::FilePath& file_path, |
35 const std::string& key) { | 37 const std::string& key) { |
36 const int64 kMaxGDocSize = 4096; | 38 const int64_t kMaxGDocSize = 4096; |
37 int64 file_size = 0; | 39 int64_t file_size = 0; |
38 if (!base::GetFileSize(file_path, &file_size) || file_size > kMaxGDocSize) { | 40 if (!base::GetFileSize(file_path, &file_size) || file_size > kMaxGDocSize) { |
39 LOG(WARNING) << "File too large to be a GDoc file " << file_path.value(); | 41 LOG(WARNING) << "File too large to be a GDoc file " << file_path.value(); |
40 return std::string(); | 42 return std::string(); |
41 } | 43 } |
42 | 44 |
43 JSONFileValueDeserializer reader(file_path); | 45 JSONFileValueDeserializer reader(file_path); |
44 std::string error_message; | 46 std::string error_message; |
45 scoped_ptr<base::Value> root_value(reader.Deserialize(NULL, &error_message)); | 47 scoped_ptr<base::Value> root_value(reader.Deserialize(NULL, &error_message)); |
46 if (!root_value) { | 48 if (!root_value) { |
47 LOG(WARNING) << "Failed to parse " << file_path.value() << " as JSON." | 49 LOG(WARNING) << "Failed to parse " << file_path.value() << " as JSON." |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 GURL ReadUrlFromGDocFile(const base::FilePath& file_path) { | 135 GURL ReadUrlFromGDocFile(const base::FilePath& file_path) { |
134 return GURL(ReadStringFromGDocFile(file_path, "url")); | 136 return GURL(ReadStringFromGDocFile(file_path, "url")); |
135 } | 137 } |
136 | 138 |
137 std::string ReadResourceIdFromGDocFile(const base::FilePath& file_path) { | 139 std::string ReadResourceIdFromGDocFile(const base::FilePath& file_path) { |
138 return ReadStringFromGDocFile(file_path, "resource_id"); | 140 return ReadStringFromGDocFile(file_path, "resource_id"); |
139 } | 141 } |
140 | 142 |
141 } // namespace util | 143 } // namespace util |
142 } // namespace drive | 144 } // namespace drive |
OLD | NEW |