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

Unified Diff: chrome/browser/chromeos/gdata/gdata_files.h

Issue 10800092: Database support for GDataDirectoryService. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gdata/gdata_files.h
===================================================================
--- chrome/browser/chromeos/gdata/gdata_files.h (revision 149486)
+++ chrome/browser/chromeos/gdata/gdata_files.h (working copy)
@@ -21,11 +21,17 @@
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
+namespace base {
+class SequencedTaskRunner;
+}
+
namespace gdata {
+struct CreateDBParams;
class GDataFile;
class GDataDirectory;
class GDataDirectoryService;
+class GDataDirectoryServiceDB;
class GDataEntryProto;
class GDataDirectoryProto;
@@ -89,9 +95,8 @@
GDataDirectoryService* directory_service);
// Serialize/Parse to/from string via proto classes.
- // TODO(achuith): Correctly set up parent_ and root_ links in
- // FromProtoString.
void SerializeToString(std::string* serialized_proto) const;
+ // TODO(achuith): Get rid of this.
satorux1 2012/08/02 17:24:03 Please add a url to the bug
achuithb 2012/08/02 20:26:25 Done.
static scoped_ptr<GDataEntry> FromProtoString(
const std::string& serialized_proto);
@@ -106,7 +111,7 @@
PlatformFileInfoProto* proto);
// Converts to/from proto. Only handles the common part (i.e. does not
- // touch |file_specific_info| and |directory_specific_info|.
+ // touch |file_specific_info|).
bool FromProto(const GDataEntryProto& proto) WARN_UNUSED_RESULT;
void ToProto(GDataEntryProto* proto) const;
@@ -336,12 +341,16 @@
DISALLOW_COPY_AND_ASSIGN(GDataDirectory);
};
+// TODO(achuith,hashimoto,satorux): Move this to a separate file.
satorux1 2012/08/02 17:24:03 could you file a bug and add a url to it? I'll fin
achuithb 2012/08/02 20:26:25 Done.
// Class to handle GDataEntry* lookups, add/remove GDataEntry*.
class GDataDirectoryService {
public:
// Callback for GetEntryByResourceIdAsync.
typedef base::Callback<void(GDataEntry* entry)> GetEntryByResourceIdCallback;
+ // Map of resource id and serialized GDataEntry.
+ typedef std::map<std::string, std::string> SerializedMap;
+
GDataDirectoryService();
~GDataDirectoryService();
@@ -400,18 +409,44 @@
void SerializeToString(std::string* serialized_proto) const;
bool ParseFromString(const std::string& serialized_proto);
+ // Restore from and save to database.
satorux1 2012/08/02 17:24:03 Restores/saves
achuithb 2012/08/02 20:26:25 Done.
+ void InitFromDB(const FilePath& db_path,
+ base::SequencedTaskRunner* blocking_task_runner,
+ LoadRootFeedParams* load_params,
+ const base::Closure& callback);
+ void SaveToDB();
+
private:
// A map table of file's resource string to its GDataFile* entry.
typedef std::map<std::string, GDataEntry*> ResourceMap;
- scoped_ptr<GDataDirectory> root_; // Stored in the serialized proto.
+ // Initialize the resource map using serialized_resources fetched from the db.
satorux1 2012/08/02 17:24:03 please fix other paces too
achuithb 2012/08/02 20:26:25 Done.
+ void InitResourceMap(CreateDBParams* create_params,
+ LoadRootFeedParams* load_params,
+ const base::Closure& callback);
+
+ // Clear root_ and the resource map.
+ void ClearRoot();
+
+ // Create GDataEntry from serialized string.
+ scoped_ptr<GDataEntry> FromProtoString(
+ const std::string& serialized_proto);
+
+ // Private data members.
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
+ scoped_ptr<GDataDirectoryServiceDB> directory_service_db_;
+
ResourceMap resource_map_;
+ scoped_ptr<GDataDirectory> root_; // Stored in the serialized proto.
+
base::Time last_serialized_;
size_t serialized_size_;
int largest_changestamp_; // Stored in the serialized proto.
ContentOrigin origin_;
+ base::WeakPtrFactory<GDataDirectoryService> ui_weak_ptr_factory_;
satorux1 2012/08/02 17:24:03 omit "ui_"?
achuithb 2012/08/02 20:26:25 Done.
+
DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService);
};

Powered by Google App Engine
This is Rietveld 408576698