| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/saved_files_service.h" | 5 #include "apps/saved_files_service.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void AddSavedFileEntry(ExtensionPrefs* prefs, | 58 void AddSavedFileEntry(ExtensionPrefs* prefs, |
| 59 const std::string& extension_id, | 59 const std::string& extension_id, |
| 60 const SavedFileEntry& file_entry) { | 60 const SavedFileEntry& file_entry) { |
| 61 ExtensionPrefs::ScopedDictionaryUpdate update( | 61 ExtensionPrefs::ScopedDictionaryUpdate update( |
| 62 prefs, extension_id, kFileEntries); | 62 prefs, extension_id, kFileEntries); |
| 63 base::DictionaryValue* file_entries = update.Get(); | 63 base::DictionaryValue* file_entries = update.Get(); |
| 64 if (!file_entries) | 64 if (!file_entries) |
| 65 file_entries = update.Create(); | 65 file_entries = update.Create(); |
| 66 DCHECK(!file_entries->GetDictionaryWithoutPathExpansion(file_entry.id, NULL)); | 66 DCHECK(!file_entries->GetDictionaryWithoutPathExpansion(file_entry.id, NULL)); |
| 67 | 67 |
| 68 base::DictionaryValue* file_entry_dict = new base::DictionaryValue(); | 68 std::unique_ptr<base::DictionaryValue> file_entry_dict = |
| 69 base::MakeUnique<base::DictionaryValue>(); |
| 69 file_entry_dict->Set(kFileEntryPath, CreateFilePathValue(file_entry.path)); | 70 file_entry_dict->Set(kFileEntryPath, CreateFilePathValue(file_entry.path)); |
| 70 file_entry_dict->SetBoolean(kFileEntryIsDirectory, file_entry.is_directory); | 71 file_entry_dict->SetBoolean(kFileEntryIsDirectory, file_entry.is_directory); |
| 71 file_entry_dict->SetInteger(kFileEntrySequenceNumber, | 72 file_entry_dict->SetInteger(kFileEntrySequenceNumber, |
| 72 file_entry.sequence_number); | 73 file_entry.sequence_number); |
| 73 file_entries->SetWithoutPathExpansion(file_entry.id, file_entry_dict); | 74 file_entries->SetWithoutPathExpansion(file_entry.id, |
| 75 std::move(file_entry_dict)); |
| 74 } | 76 } |
| 75 | 77 |
| 76 // Updates the sequence_number of a SavedFileEntry persisted in ExtensionPrefs. | 78 // Updates the sequence_number of a SavedFileEntry persisted in ExtensionPrefs. |
| 77 void UpdateSavedFileEntry(ExtensionPrefs* prefs, | 79 void UpdateSavedFileEntry(ExtensionPrefs* prefs, |
| 78 const std::string& extension_id, | 80 const std::string& extension_id, |
| 79 const SavedFileEntry& file_entry) { | 81 const SavedFileEntry& file_entry) { |
| 80 ExtensionPrefs::ScopedDictionaryUpdate update( | 82 ExtensionPrefs::ScopedDictionaryUpdate update( |
| 81 prefs, extension_id, kFileEntries); | 83 prefs, extension_id, kFileEntries); |
| 82 base::DictionaryValue* file_entries = update.Get(); | 84 base::DictionaryValue* file_entries = update.Get(); |
| 83 DCHECK(file_entries); | 85 DCHECK(file_entries); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 void SavedFilesService::SetLruSizeForTest(int size) { | 444 void SavedFilesService::SetLruSizeForTest(int size) { |
| 443 g_max_saved_file_entries = size; | 445 g_max_saved_file_entries = size; |
| 444 } | 446 } |
| 445 | 447 |
| 446 // static | 448 // static |
| 447 void SavedFilesService::ClearLruSizeForTest() { | 449 void SavedFilesService::ClearLruSizeForTest() { |
| 448 g_max_saved_file_entries = kMaxSavedFileEntries; | 450 g_max_saved_file_entries = kMaxSavedFileEntries; |
| 449 } | 451 } |
| 450 | 452 |
| 451 } // namespace apps | 453 } // namespace apps |
| OLD | NEW |