OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/fileapi/file_system_url.h" | 5 #include "webkit/fileapi/file_system_url.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "net/base/escape.h" | 11 #include "net/base/escape.h" |
12 #include "webkit/fileapi/external_mount_points.h" | 12 #include "webkit/fileapi/external_mount_points.h" |
13 #include "webkit/fileapi/file_system_types.h" | 13 #include "webkit/fileapi/file_system_types.h" |
14 #include "webkit/fileapi/file_system_util.h" | 14 #include "webkit/fileapi/file_system_util.h" |
15 #include "webkit/fileapi/isolated_context.h" | 15 #include "webkit/fileapi/isolated_context.h" |
16 | 16 |
17 namespace fileapi { | 17 namespace fileapi { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 FileSystemURL::FileSystemURL() | 23 FileSystemURL::FileSystemURL() |
24 : is_valid_(false), | 24 : is_valid_(false), |
25 type_(kFileSystemTypeUnknown), | 25 mount_type_(kFileSystemTypeUnknown), |
26 mount_type_(kFileSystemTypeUnknown) { | 26 type_(kFileSystemTypeUnknown) { |
27 } | 27 } |
28 | 28 |
29 // static | 29 // static |
30 FileSystemURL FileSystemURL::CreateForTest(const GURL& url) { | 30 FileSystemURL FileSystemURL::CreateForTest(const GURL& url) { |
31 return FileSystemURL(url); | 31 return FileSystemURL(url); |
32 } | 32 } |
33 | 33 |
34 FileSystemURL FileSystemURL::CreateForTest(const GURL& origin, | 34 FileSystemURL FileSystemURL::CreateForTest(const GURL& origin, |
35 FileSystemType type, | 35 FileSystemType type, |
36 const base::FilePath& path) { | 36 const base::FilePath& path) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (type) | 92 if (type) |
93 *type = file_system_type; | 93 *type = file_system_type; |
94 if (file_path) | 94 if (file_path) |
95 *file_path = converted_path.NormalizePathSeparators(). | 95 *file_path = converted_path.NormalizePathSeparators(). |
96 StripTrailingSeparators(); | 96 StripTrailingSeparators(); |
97 | 97 |
98 return true; | 98 return true; |
99 } | 99 } |
100 | 100 |
101 FileSystemURL::FileSystemURL(const GURL& url) | 101 FileSystemURL::FileSystemURL(const GURL& url) |
102 : type_(kFileSystemTypeUnknown), | 102 : mount_type_(kFileSystemTypeUnknown), |
103 mount_type_(kFileSystemTypeUnknown) { | 103 type_(kFileSystemTypeUnknown) { |
104 is_valid_ = ParseFileSystemSchemeURL(url, &origin_, &type_, &path_); | 104 is_valid_ = ParseFileSystemSchemeURL(url, &origin_, &type_, &path_); |
105 virtual_path_ = path_; | 105 virtual_path_ = path_; |
106 mount_type_ = type_; | 106 mount_type_ = type_; |
107 } | 107 } |
108 | 108 |
109 FileSystemURL::FileSystemURL(const GURL& origin, | 109 FileSystemURL::FileSystemURL(const GURL& origin, |
110 FileSystemType type, | 110 FileSystemType type, |
111 const base::FilePath& path) | 111 const base::FilePath& path) |
112 : is_valid_(true), | 112 : is_valid_(true), |
113 origin_(origin), | 113 origin_(origin), |
| 114 mount_type_(type), |
| 115 virtual_path_(path.NormalizePathSeparators()), |
114 type_(type), | 116 type_(type), |
115 mount_type_(type), | 117 path_(path.NormalizePathSeparators()) { |
116 path_(path.NormalizePathSeparators()), | |
117 virtual_path_(path.NormalizePathSeparators()) { | |
118 } | 118 } |
119 | 119 |
120 FileSystemURL::FileSystemURL(const GURL& origin, | 120 FileSystemURL::FileSystemURL(const GURL& origin, |
121 FileSystemType mount_type, | 121 FileSystemType mount_type, |
122 const base::FilePath& virtual_path, | 122 const base::FilePath& virtual_path, |
123 const std::string& filesystem_id, | 123 const std::string& mount_filesystem_id, |
124 FileSystemType cracked_type, | 124 FileSystemType cracked_type, |
125 const base::FilePath& cracked_path) | 125 const base::FilePath& cracked_path, |
| 126 const std::string& filesystem_id) |
126 : is_valid_(true), | 127 : is_valid_(true), |
127 origin_(origin), | 128 origin_(origin), |
| 129 mount_type_(mount_type), |
| 130 virtual_path_(virtual_path.NormalizePathSeparators()), |
| 131 mount_filesystem_id_(mount_filesystem_id), |
128 type_(cracked_type), | 132 type_(cracked_type), |
129 mount_type_(mount_type), | |
130 path_(cracked_path.NormalizePathSeparators()), | 133 path_(cracked_path.NormalizePathSeparators()), |
131 filesystem_id_(filesystem_id), | 134 filesystem_id_(filesystem_id) { |
132 virtual_path_(virtual_path.NormalizePathSeparators()) { | |
133 } | 135 } |
134 | 136 |
135 FileSystemURL::~FileSystemURL() {} | 137 FileSystemURL::~FileSystemURL() {} |
136 | 138 |
137 std::string FileSystemURL::DebugString() const { | 139 std::string FileSystemURL::DebugString() const { |
138 if (!is_valid_) | 140 if (!is_valid_) |
139 return "invalid filesystem: URL"; | 141 return "invalid filesystem: URL"; |
140 std::ostringstream ss; | 142 std::ostringstream ss; |
141 ss << GetFileSystemRootURI(origin_, mount_type_); | 143 ss << GetFileSystemRootURI(origin_, mount_type_); |
142 | 144 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 if (lhs.origin_ != rhs.origin_) | 176 if (lhs.origin_ != rhs.origin_) |
175 return lhs.origin_ < rhs.origin_; | 177 return lhs.origin_ < rhs.origin_; |
176 if (lhs.type_ != rhs.type_) | 178 if (lhs.type_ != rhs.type_) |
177 return lhs.type_ < rhs.type_; | 179 return lhs.type_ < rhs.type_; |
178 if (lhs.filesystem_id_ != rhs.filesystem_id_) | 180 if (lhs.filesystem_id_ != rhs.filesystem_id_) |
179 return lhs.filesystem_id_ < rhs.filesystem_id_; | 181 return lhs.filesystem_id_ < rhs.filesystem_id_; |
180 return lhs.path_ < rhs.path_; | 182 return lhs.path_ < rhs.path_; |
181 } | 183 } |
182 | 184 |
183 } // namespace fileapi | 185 } // namespace fileapi |
OLD | NEW |