| 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 | |
| 9 #include <algorithm> | 8 #include <algorithm> |
| 10 #include <map> | 9 #include <map> |
| 10 #include <utility> |
| 11 | 11 |
| 12 #include "apps/saved_files_service_factory.h" | 12 #include "apps/saved_files_service_factory.h" |
| 13 #include "base/containers/scoped_ptr_hash_map.h" | 13 #include "base/containers/scoped_ptr_hash_map.h" |
| 14 #include "base/value_conversions.h" | 14 #include "base/value_conversions.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "extensions/browser/extension_host.h" | 18 #include "extensions/browser/extension_host.h" |
| 19 #include "extensions/browser/extension_prefs.h" | 19 #include "extensions/browser/extension_prefs.h" |
| 20 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); | 416 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
| 417 std::vector<SavedFileEntry> saved_entries = | 417 std::vector<SavedFileEntry> saved_entries = |
| 418 GetSavedFileEntries(prefs, extension_id_); | 418 GetSavedFileEntries(prefs, extension_id_); |
| 419 for (std::vector<SavedFileEntry>::iterator it = saved_entries.begin(); | 419 for (std::vector<SavedFileEntry>::iterator it = saved_entries.begin(); |
| 420 it != saved_entries.end(); | 420 it != saved_entries.end(); |
| 421 ++it) { | 421 ++it) { |
| 422 scoped_ptr<SavedFileEntry> file_entry(new SavedFileEntry(*it)); | 422 scoped_ptr<SavedFileEntry> file_entry(new SavedFileEntry(*it)); |
| 423 const std::string& id = file_entry->id; | 423 const std::string& id = file_entry->id; |
| 424 saved_file_lru_.insert( | 424 saved_file_lru_.insert( |
| 425 std::make_pair(file_entry->sequence_number, file_entry.get())); | 425 std::make_pair(file_entry->sequence_number, file_entry.get())); |
| 426 registered_file_entries_.add(id, file_entry.Pass()); | 426 registered_file_entries_.add(id, std::move(file_entry)); |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 // static | 430 // static |
| 431 void SavedFilesService::SetMaxSequenceNumberForTest(int max_value) { | 431 void SavedFilesService::SetMaxSequenceNumberForTest(int max_value) { |
| 432 g_max_sequence_number = max_value; | 432 g_max_sequence_number = max_value; |
| 433 } | 433 } |
| 434 | 434 |
| 435 // static | 435 // static |
| 436 void SavedFilesService::ClearMaxSequenceNumberForTest() { | 436 void SavedFilesService::ClearMaxSequenceNumberForTest() { |
| 437 g_max_sequence_number = kMaxSequenceNumber; | 437 g_max_sequence_number = kMaxSequenceNumber; |
| 438 } | 438 } |
| 439 | 439 |
| 440 // static | 440 // static |
| 441 void SavedFilesService::SetLruSizeForTest(int size) { | 441 void SavedFilesService::SetLruSizeForTest(int size) { |
| 442 g_max_saved_file_entries = size; | 442 g_max_saved_file_entries = size; |
| 443 } | 443 } |
| 444 | 444 |
| 445 // static | 445 // static |
| 446 void SavedFilesService::ClearLruSizeForTest() { | 446 void SavedFilesService::ClearLruSizeForTest() { |
| 447 g_max_saved_file_entries = kMaxSavedFileEntries; | 447 g_max_saved_file_entries = kMaxSavedFileEntries; |
| 448 } | 448 } |
| 449 | 449 |
| 450 } // namespace apps | 450 } // namespace apps |
| OLD | NEW |