Index: apps/saved_files_service_impl.h |
diff --git a/apps/saved_files_service.h b/apps/saved_files_service_impl.h |
similarity index 46% |
copy from apps/saved_files_service.h |
copy to apps/saved_files_service_impl.h |
index 927f22b985869eccca6f5787920c180b37b34dad..da1c92c57c7c79b9913d632b2e35a11556c3738f 100644 |
--- a/apps/saved_files_service.h |
+++ b/apps/saved_files_service_impl.h |
@@ -2,8 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef APPS_SAVED_FILES_SERVICE_H_ |
-#define APPS_SAVED_FILES_SERVICE_H_ |
+#ifndef APPS_SAVED_FILES_SERVICE_IMPL_H_ |
+#define APPS_SAVED_FILES_SERVICE_IMPL_H_ |
#include <map> |
#include <memory> |
@@ -16,15 +16,17 @@ |
#include "components/keyed_service/core/keyed_service.h" |
#include "content/public/browser/notification_observer.h" |
#include "content/public/browser/notification_registrar.h" |
+#include "extensions/browser/api/file_system/saved_files_service.h" |
namespace content { |
class BrowserContext; |
} |
-class SavedFilesServiceUnitTest; |
-FORWARD_DECLARE_TEST(SavedFilesServiceUnitTest, RetainTwoFilesTest); |
-FORWARD_DECLARE_TEST(SavedFilesServiceUnitTest, EvictionTest); |
-FORWARD_DECLARE_TEST(SavedFilesServiceUnitTest, SequenceNumberCompactionTest); |
+class SavedFilesServiceImplUnitTest; |
+FORWARD_DECLARE_TEST(SavedFilesServiceImplUnitTest, RetainTwoFilesTest); |
+FORWARD_DECLARE_TEST(SavedFilesServiceImplUnitTest, EvictionTest); |
+FORWARD_DECLARE_TEST(SavedFilesServiceImplUnitTest, |
+ SequenceNumberCompactionTest); |
namespace extensions { |
class Extension; |
@@ -32,67 +34,31 @@ class Extension; |
namespace apps { |
-// Represents a file entry that a user has given an app permission to |
-// access. Will be persisted to disk (in the Preferences file), so should remain |
-// serializable. |
-struct SavedFileEntry { |
- SavedFileEntry(); |
- |
- SavedFileEntry(const std::string& id, |
- const base::FilePath& path, |
- bool is_directory, |
- int sequence_number); |
- |
- // The opaque id of this file entry. |
- std::string id; |
- |
- // The path to a file entry that the app had permission to access. |
- base::FilePath path; |
- |
- // Whether or not the entry refers to a directory. |
- bool is_directory; |
- |
- // The sequence number in the LRU of the file entry. The value 0 indicates |
- // that the entry is not in the LRU. |
- int sequence_number; |
-}; |
- |
// Tracks the files that apps have retained access to both while running and |
// when suspended. |
-class SavedFilesService : public KeyedService, |
- public content::NotificationObserver { |
+class SavedFilesServiceImpl : public extensions::SavedFilesService, |
+ public KeyedService, |
+ public content::NotificationObserver { |
public: |
- explicit SavedFilesService(content::BrowserContext* context); |
- ~SavedFilesService() override; |
+ explicit SavedFilesServiceImpl(content::BrowserContext* context); |
+ ~SavedFilesServiceImpl() override; |
- static SavedFilesService* Get(content::BrowserContext* context); |
+ static SavedFilesServiceImpl* Get(content::BrowserContext* context); |
- // Registers a file entry with the saved files service, making it eligible to |
- // be put into the queue. File entries that are in the retained files queue at |
- // object construction are automatically registered. |
+ // extensions::SavedFilesService: |
void RegisterFileEntry(const std::string& extension_id, |
const std::string& id, |
const base::FilePath& file_path, |
- bool is_directory); |
- |
- // If the file with |id| is not in the queue of files to be retained |
- // permanently, adds the file to the back of the queue, evicting the least |
- // recently used entry at the front of the queue if it is full. If it is |
- // already present, moves it to the back of the queue. The |id| must have been |
- // registered. |
- void EnqueueFileEntry(const std::string& extension_id, const std::string& id); |
- |
- // Returns whether the file entry with the given |id| has been registered. |
- bool IsRegistered(const std::string& extension_id, const std::string& id); |
- |
- // Gets a borrowed pointer to the file entry with the specified |id|. Returns |
- // NULL if the file entry has not been registered. |
- const SavedFileEntry* GetFileEntry(const std::string& extension_id, |
- const std::string& id); |
+ bool is_directory) override; |
+ void EnqueueFileEntry(const std::string& extension_id, |
+ const std::string& id) override; |
+ bool IsRegistered(const std::string& extension_id, |
+ const std::string& id) override; |
+ const Entry* GetFileEntry(const std::string& extension_id, |
+ const std::string& id) override; |
// Returns all registered file entries. |
- std::vector<SavedFileEntry> GetAllFileEntries( |
- const std::string& extension_id); |
+ std::vector<Entry> GetAllFileEntries(const std::string& extension_id); |
// Clears all retained files if the app does not have the |
// fileSystem.retainEntries permission. |
@@ -105,11 +71,11 @@ class SavedFilesService : public KeyedService, |
void OnApplicationTerminating(); |
private: |
- FRIEND_TEST_ALL_PREFIXES(::SavedFilesServiceUnitTest, RetainTwoFilesTest); |
- FRIEND_TEST_ALL_PREFIXES(::SavedFilesServiceUnitTest, EvictionTest); |
- FRIEND_TEST_ALL_PREFIXES(::SavedFilesServiceUnitTest, |
+ FRIEND_TEST_ALL_PREFIXES(::SavedFilesServiceImplUnitTest, RetainTwoFilesTest); |
+ FRIEND_TEST_ALL_PREFIXES(::SavedFilesServiceImplUnitTest, EvictionTest); |
+ FRIEND_TEST_ALL_PREFIXES(::SavedFilesServiceImplUnitTest, |
SequenceNumberCompactionTest); |
- friend class ::SavedFilesServiceUnitTest; |
+ friend class ::SavedFilesServiceImplUnitTest; |
// A container for the registered files for an app. |
class SavedFiles; |
@@ -138,7 +104,7 @@ class SavedFilesService : public KeyedService, |
content::NotificationRegistrar registrar_; |
content::BrowserContext* context_; |
- DISALLOW_COPY_AND_ASSIGN(SavedFilesService); |
+ DISALLOW_COPY_AND_ASSIGN(SavedFilesServiceImpl); |
}; |
} // namespace apps |