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

Side by Side Diff: storage/browser/fileapi/file_system_url.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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
OLDNEW
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/browser/fileapi/file_system_url.h" 5 #include "storage/browser/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/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "net/base/escape.h" 11 #include "net/base/escape.h"
12 #include "webkit/common/fileapi/file_system_types.h" 12 #include "storage/common/fileapi/file_system_types.h"
13 #include "webkit/common/fileapi/file_system_util.h" 13 #include "storage/common/fileapi/file_system_util.h"
14 14
15 namespace fileapi { 15 namespace storage {
16 16
17 namespace { 17 namespace {} // namespace
18
19 } // namespace
20 18
21 FileSystemURL::FileSystemURL() 19 FileSystemURL::FileSystemURL()
22 : is_valid_(false), 20 : is_valid_(false),
23 mount_type_(kFileSystemTypeUnknown), 21 mount_type_(kFileSystemTypeUnknown),
24 type_(kFileSystemTypeUnknown), 22 type_(kFileSystemTypeUnknown),
25 mount_option_(COPY_SYNC_OPTION_NO_SYNC) { 23 mount_option_(COPY_SYNC_OPTION_NO_SYNC) {
26 } 24 }
27 25
28 // static 26 // static
29 FileSystemURL FileSystemURL::CreateForTest(const GURL& url) { 27 FileSystemURL FileSystemURL::CreateForTest(const GURL& url) {
30 return FileSystemURL(url); 28 return FileSystemURL(url);
31 } 29 }
32 30
33 FileSystemURL FileSystemURL::CreateForTest(const GURL& origin, 31 FileSystemURL FileSystemURL::CreateForTest(const GURL& origin,
34 FileSystemType mount_type, 32 FileSystemType mount_type,
35 const base::FilePath& virtual_path) { 33 const base::FilePath& virtual_path) {
36 return FileSystemURL(origin, mount_type, virtual_path); 34 return FileSystemURL(origin, mount_type, virtual_path);
37 } 35 }
38 36
39 FileSystemURL::FileSystemURL(const GURL& url) 37 FileSystemURL::FileSystemURL(const GURL& url)
40 : mount_type_(kFileSystemTypeUnknown), 38 : mount_type_(kFileSystemTypeUnknown),
41 type_(kFileSystemTypeUnknown), 39 type_(kFileSystemTypeUnknown),
42 mount_option_(COPY_SYNC_OPTION_NO_SYNC) { 40 mount_option_(COPY_SYNC_OPTION_NO_SYNC) {
43 is_valid_ = ParseFileSystemSchemeURL(url, &origin_, &mount_type_, 41 is_valid_ =
44 &virtual_path_); 42 ParseFileSystemSchemeURL(url, &origin_, &mount_type_, &virtual_path_);
45 path_ = virtual_path_; 43 path_ = virtual_path_;
46 type_ = mount_type_; 44 type_ = mount_type_;
47 } 45 }
48 46
49 FileSystemURL::FileSystemURL(const GURL& origin, 47 FileSystemURL::FileSystemURL(const GURL& origin,
50 FileSystemType mount_type, 48 FileSystemType mount_type,
51 const base::FilePath& virtual_path) 49 const base::FilePath& virtual_path)
52 : is_valid_(true), 50 : is_valid_(true),
53 origin_(origin), 51 origin_(origin),
54 mount_type_(mount_type), 52 mount_type_(mount_type),
(...skipping 15 matching lines...) Expand all
70 origin_(origin), 68 origin_(origin),
71 mount_type_(mount_type), 69 mount_type_(mount_type),
72 virtual_path_(virtual_path.NormalizePathSeparators()), 70 virtual_path_(virtual_path.NormalizePathSeparators()),
73 mount_filesystem_id_(mount_filesystem_id), 71 mount_filesystem_id_(mount_filesystem_id),
74 type_(cracked_type), 72 type_(cracked_type),
75 path_(cracked_path.NormalizePathSeparators()), 73 path_(cracked_path.NormalizePathSeparators()),
76 filesystem_id_(filesystem_id), 74 filesystem_id_(filesystem_id),
77 mount_option_(mount_option) { 75 mount_option_(mount_option) {
78 } 76 }
79 77
80 FileSystemURL::~FileSystemURL() {} 78 FileSystemURL::~FileSystemURL() {
79 }
81 80
82 GURL FileSystemURL::ToGURL() const { 81 GURL FileSystemURL::ToGURL() const {
83 if (!is_valid_) 82 if (!is_valid_)
84 return GURL(); 83 return GURL();
85 84
86 std::string url = GetFileSystemRootURI(origin_, mount_type_).spec(); 85 std::string url = GetFileSystemRootURI(origin_, mount_type_).spec();
87 if (url.empty()) 86 if (url.empty())
88 return GURL(); 87 return GURL();
89 88
90 // Exactly match with DOMFileSystemBase::createFileSystemURL()'s encoding 89 // Exactly match with DOMFileSystemBase::createFileSystemURL()'s encoding
(...skipping 22 matching lines...) Expand all
113 ss << GetFileSystemTypeString(type_) << "@" << filesystem_id_ << ":"; 112 ss << GetFileSystemTypeString(type_) << "@" << filesystem_id_ << ":";
114 ss << path_.value(); 113 ss << path_.value();
115 ss << ")"; 114 ss << ")";
116 } else { 115 } else {
117 ss << path_.value(); 116 ss << path_.value();
118 } 117 }
119 return ss.str(); 118 return ss.str();
120 } 119 }
121 120
122 bool FileSystemURL::IsParent(const FileSystemURL& child) const { 121 bool FileSystemURL::IsParent(const FileSystemURL& child) const {
123 return IsInSameFileSystem(child) && 122 return IsInSameFileSystem(child) && path().IsParent(child.path());
124 path().IsParent(child.path());
125 } 123 }
126 124
127 bool FileSystemURL::IsInSameFileSystem(const FileSystemURL& other) const { 125 bool FileSystemURL::IsInSameFileSystem(const FileSystemURL& other) const {
128 return origin() == other.origin() && 126 return origin() == other.origin() && type() == other.type() &&
129 type() == other.type() &&
130 filesystem_id() == other.filesystem_id(); 127 filesystem_id() == other.filesystem_id();
131 } 128 }
132 129
133 bool FileSystemURL::operator==(const FileSystemURL& that) const { 130 bool FileSystemURL::operator==(const FileSystemURL& that) const {
134 return origin_ == that.origin_ && 131 return origin_ == that.origin_ && type_ == that.type_ &&
135 type_ == that.type_ && 132 path_ == that.path_ && filesystem_id_ == that.filesystem_id_ &&
136 path_ == that.path_ && 133 is_valid_ == that.is_valid_;
137 filesystem_id_ == that.filesystem_id_ &&
138 is_valid_ == that.is_valid_;
139 } 134 }
140 135
141 bool FileSystemURL::Comparator::operator()(const FileSystemURL& lhs, 136 bool FileSystemURL::Comparator::operator()(const FileSystemURL& lhs,
142 const FileSystemURL& rhs) const { 137 const FileSystemURL& rhs) const {
143 DCHECK(lhs.is_valid_ && rhs.is_valid_); 138 DCHECK(lhs.is_valid_ && rhs.is_valid_);
144 if (lhs.origin_ != rhs.origin_) 139 if (lhs.origin_ != rhs.origin_)
145 return lhs.origin_ < rhs.origin_; 140 return lhs.origin_ < rhs.origin_;
146 if (lhs.type_ != rhs.type_) 141 if (lhs.type_ != rhs.type_)
147 return lhs.type_ < rhs.type_; 142 return lhs.type_ < rhs.type_;
148 if (lhs.filesystem_id_ != rhs.filesystem_id_) 143 if (lhs.filesystem_id_ != rhs.filesystem_id_)
149 return lhs.filesystem_id_ < rhs.filesystem_id_; 144 return lhs.filesystem_id_ < rhs.filesystem_id_;
150 return lhs.path_ < rhs.path_; 145 return lhs.path_ < rhs.path_;
151 } 146 }
152 147
153 } // namespace fileapi 148 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/file_system_url.h ('k') | storage/browser/fileapi/file_system_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698