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

Side by Side Diff: apps/saved_files_service.h

Issue 14607023: Add support for persistent file access in apps. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef APPS_SAVED_FILES_SERVICE_H_
6 #define APPS_SAVED_FILES_SERVICE_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
12
13 #include "base/files/file_path.h"
14 #include "base/stl_util.h"
15 #include "chrome/browser/profiles/profile_keyed_service.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18
19 class Profile;
20
21 namespace apps {
22
23 // Represents a file entry that a user has given an extension permission to
Matt Giuca 2013/05/17 08:28:45 s/extension/app
Sam McNally 2013/05/20 01:17:13 Done.
24 // access. Intended to be persisted to disk (in the Preferences file), so should
25 // remain serializable.
26 struct SavedFileEntry {
Matt Giuca 2013/05/17 08:28:45 If it's serializable, how do you serialize it? Sho
Sam McNally 2013/05/20 01:17:13 See AddSavedFileEntry and friends in saved_files_s
27 SavedFileEntry()
28 : writable(false),
29 sequence_number(0) {}
30
31 SavedFileEntry(const std::string& id,
32 const base::FilePath& path,
33 bool writable,
34 int sequence_number)
35 : id(id),
36 path(path),
37 writable(writable),
38 sequence_number(sequence_number) {}
39
40 std::string id;
Matt Giuca 2013/05/17 08:28:45 Document (briefly) each of these fields.
Sam McNally 2013/05/20 01:17:13 Done.
41 base::FilePath path;
42 bool writable;
43 int sequence_number;
44 };
45
46 class SavedFilesService : public ProfileKeyedService,
47 public content::NotificationObserver {
48 public:
49 explicit SavedFilesService(Profile* profile);
50 virtual ~SavedFilesService();
51
52 static SavedFilesService* Get(Profile* profile);
53
54 void RetainFileEntry(const std::string& extension_id,
Matt Giuca 2013/05/17 08:28:45 Document.
Sam McNally 2013/05/20 01:17:13 Done.
55 const std::string& id,
56 const base::FilePath& file_path,
57 bool writable);
58
59 void MoveEntryToFrontOfQueue(const std::string& extension_id,
Matt Giuca 2013/05/17 08:28:45 Document.
Sam McNally 2013/05/20 01:17:13 Done.
60 const std::string& id);
61
62 bool IsRetained(const std::string& extension_id, const std::string& id);
Matt Giuca 2013/05/17 08:28:45 Document.
Sam McNally 2013/05/20 01:17:13 Done.
63
64 bool GetFileEntry(const std::string& extension_id,
Matt Giuca 2013/05/17 08:28:45 Document.
Sam McNally 2013/05/20 01:17:13 Done.
65 const std::string& id,
66 SavedFileEntry* out);
67
68 std::vector<SavedFileEntry> GetAllFileEntries(
Matt Giuca 2013/05/17 08:28:45 Document.
Sam McNally 2013/05/20 01:17:13 Done.
69 const std::string& extension_id);
70
71 void ClearExtensionForTest(const std::string& extension_id);
Matt Giuca 2013/05/17 08:28:45 Document.
Sam McNally 2013/05/20 01:17:13 Done.
72
73 static void SetMaxSequenceNumberForTest(int max_value);
Matt Giuca 2013/05/17 08:28:45 Document these four, and explain (in a paragraph a
Sam McNally 2013/05/20 01:17:13 Done.
74 static void ClearMaxSequenceNumberForTest();
75 static void SetLruSizeForTest(int size);
76 static void ClearLruSizeForTest();
77
78 private:
79 class SavedFiles;
80
81 // content::NotificationObserver.
82 virtual void Observe(int type,
83 const content::NotificationSource& source,
84 const content::NotificationDetails& details) OVERRIDE;
85
86 SavedFiles* GetOrInsert(const std::string& extension_id);
87
88 void ClearExtension(const std::string& extension_id);
89
90 std::map<std::string, SavedFiles*> extension_id_to_saved_files_;
91 STLValueDeleter<std::map<std::string, SavedFiles*> >
92 extension_id_to_saved_files_deleter_;
93 std::set<std::string> extensions_to_clear_;
94 content::NotificationRegistrar registrar_;
95 Profile* profile_;
96
97 DISALLOW_COPY_AND_ASSIGN(SavedFilesService);
98 };
99
100 } // namespace apps
101
102 #endif // APPS_SAVED_FILES_SERVICE_H_
OLDNEW
« no previous file with comments | « apps/apps.gypi ('k') | apps/saved_files_service.cc » ('j') | apps/saved_files_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698