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

Side by Side Diff: components/arc/test/fake_file_system_instance.cc

Issue 2914433002: arc: Use the MIME type returned by the container to handle content URLs (Closed)
Patch Set: Profile check Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/arc/test/fake_file_system_instance.h" 5 #include "components/arc/test/fake_file_system_instance.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 document->last_modified = doc.last_modified; 57 document->last_modified = doc.last_modified;
58 return document; 58 return document;
59 } 59 }
60 60
61 } // namespace 61 } // namespace
62 62
63 FakeFileSystemInstance::File::File(const File& that) = default; 63 FakeFileSystemInstance::File::File(const File& that) = default;
64 64
65 FakeFileSystemInstance::File::File(const std::string& url, 65 FakeFileSystemInstance::File::File(const std::string& url,
66 const std::string& content, 66 const std::string& content,
67 const std::string& mime_type,
67 Seekable seekable) 68 Seekable seekable)
68 : url(url), content(content), seekable(seekable) {} 69 : url(url), content(content), mime_type(mime_type), seekable(seekable) {}
69 70
70 FakeFileSystemInstance::File::~File() = default; 71 FakeFileSystemInstance::File::~File() = default;
71 72
72 FakeFileSystemInstance::Document::Document(const Document& that) = default; 73 FakeFileSystemInstance::Document::Document(const Document& that) = default;
73 74
74 FakeFileSystemInstance::Document::Document( 75 FakeFileSystemInstance::Document::Document(
75 const std::string& authority, 76 const std::string& authority,
76 const std::string& document_id, 77 const std::string& document_id,
77 const std::string& parent_document_id, 78 const std::string& parent_document_id,
78 const std::string& display_name, 79 const std::string& display_name,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (iter == files_.end()) { 164 if (iter == files_.end()) {
164 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 165 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
165 base::Bind(callback, -1)); 166 base::Bind(callback, -1));
166 return; 167 return;
167 } 168 }
168 const File& file = iter->second; 169 const File& file = iter->second;
169 base::ThreadTaskRunnerHandle::Get()->PostTask( 170 base::ThreadTaskRunnerHandle::Get()->PostTask(
170 FROM_HERE, base::Bind(callback, file.content.size())); 171 FROM_HERE, base::Bind(callback, file.content.size()));
171 } 172 }
172 173
174 void FakeFileSystemInstance::GetMimeType(const std::string& url,
175 const GetMimeTypeCallback& callback) {
176 DCHECK(thread_checker_.CalledOnValidThread());
177 auto iter = files_.find(url);
178 if (iter == files_.end()) {
179 base::ThreadTaskRunnerHandle::Get()->PostTask(
180 FROM_HERE, base::Bind(callback, base::Optional<std::string>()));
dcheng 2017/06/01 11:06:44 Ditto: prefer base::nullopt
hashimoto 2017/06/01 11:30:16 Done.
181 return;
182 }
183 const File& file = iter->second;
184 base::ThreadTaskRunnerHandle::Get()->PostTask(
185 FROM_HERE, base::Bind(callback, file.mime_type));
186 }
187
173 void FakeFileSystemInstance::OpenFileToRead( 188 void FakeFileSystemInstance::OpenFileToRead(
174 const std::string& url, 189 const std::string& url,
175 const OpenFileToReadCallback& callback) { 190 const OpenFileToReadCallback& callback) {
176 DCHECK(thread_checker_.CalledOnValidThread()); 191 DCHECK(thread_checker_.CalledOnValidThread());
177 auto iter = files_.find(url); 192 auto iter = files_.find(url);
178 if (iter == files_.end()) { 193 if (iter == files_.end()) {
179 base::ThreadTaskRunnerHandle::Get()->PostTask( 194 base::ThreadTaskRunnerHandle::Get()->PostTask(
180 FROM_HERE, base::Bind(callback, base::Passed(mojo::ScopedHandle()))); 195 FROM_HERE, base::Bind(callback, base::Passed(mojo::ScopedHandle())));
181 return; 196 return;
182 } 197 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 base::Bind(callback, true)); 273 base::Bind(callback, true));
259 } 274 }
260 275
261 void FakeFileSystemInstance::RequestMediaScan( 276 void FakeFileSystemInstance::RequestMediaScan(
262 const std::vector<std::string>& paths) { 277 const std::vector<std::string>& paths) {
263 DCHECK(thread_checker_.CalledOnValidThread()); 278 DCHECK(thread_checker_.CalledOnValidThread());
264 // Do nothing and pretend we scaned them. 279 // Do nothing and pretend we scaned them.
265 } 280 }
266 281
267 } // namespace arc 282 } // namespace arc
OLDNEW
« components/arc/common/file_system.mojom ('K') | « components/arc/test/fake_file_system_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698