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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fake_provided_file_system.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 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 "chrome/browser/chromeos/file_system_provider/fake_provided_file_system .h" 5 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system .h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/memory/ptr_util.h"
11 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
12 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
13 14
14 namespace chromeos { 15 namespace chromeos {
15 namespace file_system_provider { 16 namespace file_system_provider {
16 namespace { 17 namespace {
17 18
18 const char kFakeFileName[] = "hello.txt"; 19 const char kFakeFileName[] = "hello.txt";
19 const char kFakeFileText[] = 20 const char kFakeFileText[] =
20 "This is a testing file. Lorem ipsum dolor sit amet est."; 21 "This is a testing file. Lorem ipsum dolor sit amet est.";
21 const size_t kFakeFileSize = sizeof(kFakeFileText) - 1u; 22 const size_t kFakeFileSize = sizeof(kFakeFileText) - 1u;
22 const char kFakeFileModificationTime[] = "Fri Apr 25 01:47:53 UTC 2014"; 23 const char kFakeFileModificationTime[] = "Fri Apr 25 01:47:53 UTC 2014";
23 const char kFakeFileMimeType[] = "text/plain"; 24 const char kFakeFileMimeType[] = "text/plain";
24 25
25 } // namespace 26 } // namespace
26 27
27 const base::FilePath::CharType kFakeFilePath[] = 28 const base::FilePath::CharType kFakeFilePath[] =
28 FILE_PATH_LITERAL("/hello.txt"); 29 FILE_PATH_LITERAL("/hello.txt");
29 30
30 FakeEntry::FakeEntry() { 31 FakeEntry::FakeEntry() {
31 } 32 }
32 33
33 FakeEntry::FakeEntry(scoped_ptr<EntryMetadata> metadata, 34 FakeEntry::FakeEntry(std::unique_ptr<EntryMetadata> metadata,
34 const std::string& contents) 35 const std::string& contents)
35 : metadata(std::move(metadata)), contents(contents) {} 36 : metadata(std::move(metadata)), contents(contents) {}
36 37
37 FakeEntry::~FakeEntry() { 38 FakeEntry::~FakeEntry() {
38 } 39 }
39 40
40 FakeProvidedFileSystem::FakeProvidedFileSystem( 41 FakeProvidedFileSystem::FakeProvidedFileSystem(
41 const ProvidedFileSystemInfo& file_system_info) 42 const ProvidedFileSystemInfo& file_system_info)
42 : file_system_info_(file_system_info), 43 : file_system_info_(file_system_info),
43 last_file_handle_(0), 44 last_file_handle_(0),
(...skipping 10 matching lines...) Expand all
54 FakeProvidedFileSystem::~FakeProvidedFileSystem() {} 55 FakeProvidedFileSystem::~FakeProvidedFileSystem() {}
55 56
56 void FakeProvidedFileSystem::AddEntry(const base::FilePath& entry_path, 57 void FakeProvidedFileSystem::AddEntry(const base::FilePath& entry_path,
57 bool is_directory, 58 bool is_directory,
58 const std::string& name, 59 const std::string& name,
59 int64_t size, 60 int64_t size,
60 base::Time modification_time, 61 base::Time modification_time,
61 std::string mime_type, 62 std::string mime_type,
62 std::string contents) { 63 std::string contents) {
63 DCHECK(entries_.find(entry_path) == entries_.end()); 64 DCHECK(entries_.find(entry_path) == entries_.end());
64 scoped_ptr<EntryMetadata> metadata(new EntryMetadata); 65 std::unique_ptr<EntryMetadata> metadata(new EntryMetadata);
65 66
66 metadata->is_directory.reset(new bool(is_directory)); 67 metadata->is_directory.reset(new bool(is_directory));
67 metadata->name.reset(new std::string(name)); 68 metadata->name.reset(new std::string(name));
68 metadata->size.reset(new int64_t(size)); 69 metadata->size.reset(new int64_t(size));
69 metadata->modification_time.reset(new base::Time(modification_time)); 70 metadata->modification_time.reset(new base::Time(modification_time));
70 metadata->mime_type.reset(new std::string(mime_type)); 71 metadata->mime_type.reset(new std::string(mime_type));
71 72
72 entries_[entry_path] = 73 entries_[entry_path] =
73 make_linked_ptr(new FakeEntry(std::move(metadata), contents)); 74 make_linked_ptr(new FakeEntry(std::move(metadata), contents));
74 } 75 }
(...skipping 12 matching lines...) Expand all
87 return PostAbortableTask(base::Bind(callback, base::File::FILE_OK)); 88 return PostAbortableTask(base::Bind(callback, base::File::FILE_OK));
88 } 89 }
89 90
90 AbortCallback FakeProvidedFileSystem::GetMetadata( 91 AbortCallback FakeProvidedFileSystem::GetMetadata(
91 const base::FilePath& entry_path, 92 const base::FilePath& entry_path,
92 ProvidedFileSystemInterface::MetadataFieldMask fields, 93 ProvidedFileSystemInterface::MetadataFieldMask fields,
93 const ProvidedFileSystemInterface::GetMetadataCallback& callback) { 94 const ProvidedFileSystemInterface::GetMetadataCallback& callback) {
94 const Entries::const_iterator entry_it = entries_.find(entry_path); 95 const Entries::const_iterator entry_it = entries_.find(entry_path);
95 96
96 if (entry_it == entries_.end()) { 97 if (entry_it == entries_.end()) {
97 return PostAbortableTask( 98 return PostAbortableTask(base::Bind(
98 base::Bind(callback, 99 callback, base::Passed(base::WrapUnique<EntryMetadata>(NULL)),
99 base::Passed(make_scoped_ptr<EntryMetadata>(NULL)), 100 base::File::FILE_ERROR_NOT_FOUND));
100 base::File::FILE_ERROR_NOT_FOUND));
101 } 101 }
102 102
103 scoped_ptr<EntryMetadata> metadata(new EntryMetadata); 103 std::unique_ptr<EntryMetadata> metadata(new EntryMetadata);
104 if (fields & ProvidedFileSystemInterface::METADATA_FIELD_IS_DIRECTORY) { 104 if (fields & ProvidedFileSystemInterface::METADATA_FIELD_IS_DIRECTORY) {
105 metadata->is_directory.reset( 105 metadata->is_directory.reset(
106 new bool(*entry_it->second->metadata->is_directory)); 106 new bool(*entry_it->second->metadata->is_directory));
107 } 107 }
108 if (fields & ProvidedFileSystemInterface::METADATA_FIELD_NAME) 108 if (fields & ProvidedFileSystemInterface::METADATA_FIELD_NAME)
109 metadata->name.reset(new std::string(*entry_it->second->metadata->name)); 109 metadata->name.reset(new std::string(*entry_it->second->metadata->name));
110 if (fields & ProvidedFileSystemInterface::METADATA_FIELD_SIZE) 110 if (fields & ProvidedFileSystemInterface::METADATA_FIELD_SIZE)
111 metadata->size.reset(new int64_t(*entry_it->second->metadata->size)); 111 metadata->size.reset(new int64_t(*entry_it->second->metadata->size));
112 if (fields & ProvidedFileSystemInterface::METADATA_FIELD_MODIFICATION_TIME) { 112 if (fields & ProvidedFileSystemInterface::METADATA_FIELD_MODIFICATION_TIME) {
113 metadata->modification_time.reset( 113 metadata->modification_time.reset(
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 void FakeProvidedFileSystem::RemoveObserver( 390 void FakeProvidedFileSystem::RemoveObserver(
391 ProvidedFileSystemObserver* observer) { 391 ProvidedFileSystemObserver* observer) {
392 DCHECK(observer); 392 DCHECK(observer);
393 observers_.RemoveObserver(observer); 393 observers_.RemoveObserver(observer);
394 } 394 }
395 395
396 void FakeProvidedFileSystem::Notify( 396 void FakeProvidedFileSystem::Notify(
397 const base::FilePath& entry_path, 397 const base::FilePath& entry_path,
398 bool recursive, 398 bool recursive,
399 storage::WatcherManager::ChangeType change_type, 399 storage::WatcherManager::ChangeType change_type,
400 scoped_ptr<ProvidedFileSystemObserver::Changes> changes, 400 std::unique_ptr<ProvidedFileSystemObserver::Changes> changes,
401 const std::string& tag, 401 const std::string& tag,
402 const storage::AsyncFileUtil::StatusCallback& callback) { 402 const storage::AsyncFileUtil::StatusCallback& callback) {
403 NOTREACHED(); 403 NOTREACHED();
404 callback.Run(base::File::FILE_ERROR_SECURITY); 404 callback.Run(base::File::FILE_ERROR_SECURITY);
405 } 405 }
406 406
407 void FakeProvidedFileSystem::Configure( 407 void FakeProvidedFileSystem::Configure(
408 const storage::AsyncFileUtil::StatusCallback& callback) { 408 const storage::AsyncFileUtil::StatusCallback& callback) {
409 NOTREACHED(); 409 NOTREACHED();
410 callback.Run(base::File::FILE_ERROR_SECURITY); 410 callback.Run(base::File::FILE_ERROR_SECURITY);
(...skipping 23 matching lines...) Expand all
434 } 434 }
435 435
436 void FakeProvidedFileSystem::AbortMany(const std::vector<int>& task_ids) { 436 void FakeProvidedFileSystem::AbortMany(const std::vector<int>& task_ids) {
437 for (size_t i = 0; i < task_ids.size(); ++i) { 437 for (size_t i = 0; i < task_ids.size(); ++i) {
438 tracker_.TryCancel(task_ids[i]); 438 tracker_.TryCancel(task_ids[i]);
439 } 439 }
440 } 440 }
441 441
442 } // namespace file_system_provider 442 } // namespace file_system_provider
443 } // namespace chromeos 443 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698