gdata: Move GDataCache::CacheEntry out of GDataCache
Along the way, rename it to GDataCacheEntry to be consistent
with other classes, and put it in a separate header file.
FWIW, nested classes are usually avoided.
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Nested_Classes
BUG=136625
TEST=out/Release/unit_tests --gtest_filter=GData*
Review URL: https://chromiumcodereview.appspot.com/10690149
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146236 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
index a34a36e..4a157b36 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
@@ -260,7 +260,7 @@
ScopedVector<gdata::DriveWebAppInfo> info;
registry->GetWebAppsForFile(*iter, std::string(""), &info);
std::vector<gdata::DriveWebAppInfo*> info_ptrs;
- info.release(&info_ptrs); // so they don't go away prematurely.
+ info.release(&info_ptrs); // so they don't go away prematurely.
std::set<std::string> apps_for_this_file;
for (std::vector<gdata::DriveWebAppInfo*>::iterator
apps = info_ptrs.begin(); apps != info_ptrs.end(); ++apps) {
@@ -1877,7 +1877,7 @@
void GetGDataFilePropertiesFunction::CacheStateReceived(
base::DictionaryValue* property_dict,
bool /* success */,
- const gdata::GDataCache::CacheEntry& cache_entry) {
+ const gdata::GDataCacheEntry& cache_entry) {
// In case of an error (i.e. success is false), cache_entry.cache_state is
// set to CACHE_STATE_NONE.
property_dict->SetBoolean("isPinned", cache_entry.IsPinned());
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.h b/chrome/browser/chromeos/extensions/file_browser_private_api.h
index c8ebc4f..46eff29 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.h
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.h
@@ -466,7 +466,7 @@
void CacheStateReceived(base::DictionaryValue* property_dict,
bool success,
- const gdata::GDataCache::CacheEntry& cache_entry);
+ const gdata::GDataCacheEntry& cache_entry);
size_t current_index_;
base::ListValue* path_list_;
diff --git a/chrome/browser/chromeos/gdata/gdata_cache.cc b/chrome/browser/chromeos/gdata/gdata_cache.cc
index 1585eaa..02df3b9 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache.cc
+++ b/chrome/browser/chromeos/gdata/gdata_cache.cc
@@ -231,7 +231,7 @@
void CollectBacklog(std::vector<std::string>* to_fetch,
std::vector<std::string>* to_upload,
const std::string& resource_id,
- const GDataCache::CacheEntry& cache_entry) {
+ const GDataCacheEntry& cache_entry) {
DCHECK(to_fetch);
DCHECK(to_upload);
@@ -246,7 +246,7 @@
// present (cached locally).
void CollectExistingPinnedFile(std::vector<std::string>* resource_ids,
const std::string& resource_id,
- const GDataCache::CacheEntry& cache_entry) {
+ const GDataCacheEntry& cache_entry) {
DCHECK(resource_ids);
if (cache_entry.IsPinned() && cache_entry.IsPresent())
@@ -323,9 +323,9 @@
// Runs callback with pointers dereferenced.
// Used to implement GetCacheEntryOnUIThread().
void RunGetCacheEntryCallback(
- const GDataCache::GetCacheEntryCallback& callback,
+ const GetCacheEntryCallback& callback,
bool* success,
- GDataCache::CacheEntry* cache_entry) {
+ GDataCacheEntry* cache_entry) {
DCHECK(success);
DCHECK(cache_entry);
@@ -335,7 +335,7 @@
} // namespace
-std::string GDataCache::CacheEntry::ToString() const {
+std::string GDataCacheEntry::ToString() const {
std::vector<std::string> cache_states;
if (IsPresent())
cache_states.push_back("present");
@@ -428,7 +428,7 @@
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
bool* success = new bool(false);
- GDataCache::CacheEntry* cache_entry = new GDataCache::CacheEntry;
+ GDataCacheEntry* cache_entry = new GDataCacheEntry;
pool_->GetSequencedTaskRunner(sequence_token_)->PostTaskAndReply(
FROM_HERE,
base::Bind(&GDataCache::GetCacheEntryHelper,
@@ -711,7 +711,7 @@
base::Bind(&GDataCache::Initialize, base::Unretained(this)));
}
-scoped_ptr<GDataCache::CacheEntry> GDataCache::GetCacheEntry(
+scoped_ptr<GDataCacheEntry> GDataCache::GetCacheEntry(
const std::string& resource_id,
const std::string& md5) {
AssertOnSequencedWorkerPool();
@@ -780,7 +780,7 @@
DCHECK(error);
DCHECK(cache_file_path);
- scoped_ptr<CacheEntry> cache_entry = GetCacheEntry(
+ scoped_ptr<GDataCacheEntry> cache_entry = GetCacheEntry(
resource_id, md5);
if (cache_entry.get() && cache_entry->IsPresent()) {
CachedFileOrigin file_origin;
@@ -794,7 +794,7 @@
*cache_file_path = GetCacheFilePath(
resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ GetSubDirectoryType(*cache_entry),
file_origin);
*error = base::PLATFORM_FILE_OK;
} else {
@@ -812,10 +812,10 @@
FilePath dest_path;
FilePath symlink_path;
- CacheEntry new_cache_entry(md5, CACHE_STATE_NONE);
+ GDataCacheEntry new_cache_entry(md5, CACHE_STATE_NONE);
CacheSubDirectoryType sub_dir_type = CACHE_TYPE_TMP;
- scoped_ptr<CacheEntry> cache_entry = GetCacheEntry(resource_id, md5);
+ scoped_ptr<GDataCacheEntry> cache_entry = GetCacheEntry(resource_id, md5);
// If file was previously pinned, store it in persistent dir and create
// symlink in pinned dir.
@@ -897,10 +897,10 @@
FilePath dest_path;
FilePath symlink_path;
bool create_symlink = true;
- CacheEntry new_cache_entry(md5, CACHE_STATE_NONE);
+ GDataCacheEntry new_cache_entry(md5, CACHE_STATE_NONE);
CacheSubDirectoryType sub_dir_type = CACHE_TYPE_PERSISTENT;
- scoped_ptr<CacheEntry> cache_entry = GetCacheEntry(resource_id, md5);
+ scoped_ptr<GDataCacheEntry> cache_entry = GetCacheEntry(resource_id, md5);
if (!cache_entry.get()) { // Entry does not exist in cache.
// Set both |dest_path| and |source_path| to /dev/null, so that:
@@ -926,14 +926,14 @@
DCHECK(cache_entry->IsPersistent());
dest_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ GetSubDirectoryType(*cache_entry),
CACHED_FILE_LOCALLY_MODIFIED);
source_path = dest_path;
} else {
// Gets the current path of the file in cache.
source_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ GetSubDirectoryType(*cache_entry),
CACHED_FILE_FROM_SERVER);
// If file was pinned before but actual file blob doesn't exist in cache:
@@ -982,7 +982,7 @@
AssertOnSequencedWorkerPool();
DCHECK(error);
- scoped_ptr<CacheEntry> cache_entry = GetCacheEntry(resource_id, md5);
+ scoped_ptr<GDataCacheEntry> cache_entry = GetCacheEntry(resource_id, md5);
// Unpinning a file means its entry must exist in cache.
if (!cache_entry.get()) {
@@ -1007,14 +1007,14 @@
DCHECK(cache_entry->IsPersistent());
dest_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ GetSubDirectoryType(*cache_entry),
CACHED_FILE_LOCALLY_MODIFIED);
source_path = dest_path;
} else {
// Gets the current path of the file in cache.
source_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ GetSubDirectoryType(*cache_entry),
CACHED_FILE_FROM_SERVER);
// If file was pinned but actual file blob still doesn't exist in cache,
@@ -1049,7 +1049,7 @@
if (*error == base::PLATFORM_FILE_OK) {
// Now that file operations have completed, update cache map.
- CacheEntry new_cache_entry(md5, cache_entry->cache_state());
+ GDataCacheEntry new_cache_entry(md5, cache_entry->cache_state());
new_cache_entry.SetPinned(false);
new_cache_entry.SetPersistent(sub_dir_type == CACHE_TYPE_PERSISTENT);
metadata_->UpdateCache(resource_id, new_cache_entry);
@@ -1073,7 +1073,7 @@
DCHECK(!to_mount == (extra_extension == util::kMountedArchiveFileExtension));
// Get cache entry associated with the resource_id and md5
- scoped_ptr<CacheEntry> cache_entry = GetCacheEntry(
+ scoped_ptr<GDataCacheEntry> cache_entry = GetCacheEntry(
resource_id, md5);
if (!cache_entry.get()) {
*error = base::PLATFORM_FILE_ERROR_NOT_FOUND;
@@ -1098,7 +1098,7 @@
// Determine the source and destination paths for moving the cache blob.
FilePath source_path;
CacheSubDirectoryType dest_subdir;
- CacheEntry new_cache_entry(md5, cache_entry->cache_state());
+ GDataCacheEntry new_cache_entry(md5, cache_entry->cache_state());
if (to_mount) {
source_path = unmounted_path;
*cache_file_path = mounted_path;
@@ -1134,7 +1134,7 @@
// would have lost the md5 info during cache initialization, because the file
// would have been renamed to .local extension.
// So, search for entry in cache without comparing md5.
- scoped_ptr<CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntry(resource_id, std::string());
// Marking a file dirty means its entry and actual file blob must exist in
@@ -1191,7 +1191,7 @@
FilePath source_path = GetCacheFilePath(
resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ GetSubDirectoryType(*cache_entry),
CACHED_FILE_FROM_SERVER);
// Determine destination path.
@@ -1219,7 +1219,7 @@
if (*error == base::PLATFORM_FILE_OK) {
// Now that file operations have completed, update cache map.
- CacheEntry new_cache_entry(md5, cache_entry->cache_state());
+ GDataCacheEntry new_cache_entry(md5, cache_entry->cache_state());
new_cache_entry.SetDirty(true);
new_cache_entry.SetPersistent(sub_dir_type == CACHE_TYPE_PERSISTENT);
metadata_->UpdateCache(resource_id, new_cache_entry);
@@ -1237,7 +1237,7 @@
// would have lost the md5 info during cache initialization, because the file
// would have been renamed to .local extension.
// So, search for entry in cache without comparing md5.
- scoped_ptr<CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntry(resource_id, std::string());
// Committing a file dirty means its entry and actual file blob must exist in
@@ -1272,7 +1272,7 @@
// Get target path of symlink i.e. current path of the file in cache.
FilePath target_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ GetSubDirectoryType(*cache_entry),
CACHED_FILE_LOCALLY_MODIFIED);
// Since there's no need to move files, use |target_path| for both
@@ -1294,7 +1294,7 @@
// |md5| is the new .<md5> extension to rename the file to.
// So, search for entry in cache without comparing md5.
- scoped_ptr<CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntry(resource_id, std::string());
// Clearing a dirty file means its entry and actual file blob must exist in
@@ -1323,7 +1323,7 @@
// Get the current path of the file in cache.
FilePath source_path = GetCacheFilePath(resource_id,
md5,
- cache_entry->GetSubDirectoryType(),
+ GetSubDirectoryType(*cache_entry),
CACHED_FILE_LOCALLY_MODIFIED);
// Determine destination path.
@@ -1367,7 +1367,7 @@
if (*error == base::PLATFORM_FILE_OK) {
// Now that file operations have completed, update cache map.
- CacheEntry new_cache_entry(md5, cache_entry->cache_state());
+ GDataCacheEntry new_cache_entry(md5, cache_entry->cache_state());
new_cache_entry.SetDirty(false);
new_cache_entry.SetPersistent(sub_dir_type == CACHE_TYPE_PERSISTENT);
metadata_->UpdateCache(resource_id, new_cache_entry);
@@ -1383,7 +1383,7 @@
// RemoveFromCacheOnBlockingPool, because we would delete all cache files
// corresponding to <resource_id> regardless of the md5.
// So, search for entry in cache without taking md5 into account.
- scoped_ptr<CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntry(resource_id, std::string());
// If entry doesn't exist or is dirty or mounted in cache, nothing to do.
@@ -1494,12 +1494,12 @@
void GDataCache::GetCacheEntryHelper(const std::string& resource_id,
const std::string& md5,
bool* success,
- GDataCache::CacheEntry* cache_entry) {
+ GDataCacheEntry* cache_entry) {
AssertOnSequencedWorkerPool();
DCHECK(success);
DCHECK(cache_entry);
- scoped_ptr<GDataCache::CacheEntry> value(GetCacheEntry(resource_id, md5));
+ scoped_ptr<GDataCacheEntry> value(GetCacheEntry(resource_id, md5));
*success = value.get();
if (*success)
*cache_entry = *value;
@@ -1549,6 +1549,12 @@
return success;
}
+// static
+GDataCache::CacheSubDirectoryType GDataCache::GetSubDirectoryType(
+ const GDataCacheEntry& cache_entry) {
+ return cache_entry.IsPersistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP;
+}
+
void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) {
delete global_free_disk_getter_for_testing; // Safe to delete NULL;
global_free_disk_getter_for_testing = getter;
diff --git a/chrome/browser/chromeos/gdata/gdata_cache.h b/chrome/browser/chromeos/gdata/gdata_cache.h
index 9ad39eda..dd29b26 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache.h
+++ b/chrome/browser/chromeos/gdata/gdata_cache.h
@@ -14,6 +14,7 @@
#include "base/observer_list.h"
#include "base/platform_file.h"
#include "base/threading/sequenced_worker_pool.h"
+#include "chrome/browser/chromeos/gdata/gdata_cache_entry.h"
class Profile;
@@ -48,6 +49,13 @@
typedef base::Callback<void(const std::vector<std::string>& resource_ids)>
GetResourceIdsCallback;
+// Callback for GetCacheEntryOnUIThread.
+// |success| indicates if the operation was successful.
+// |cache_entry| is the obtained cache entry. On failure, |cache_state| is
+// set to CACHE_STATE_NONE.
+typedef base::Callback<void(bool success, const GDataCacheEntry& cache_entry)>
+ GetCacheEntryCallback;
+
// GDataCache is used to maintain cache states of GDataFileSystem.
//
// All non-static public member functions, unless mentioned otherwise (see
@@ -77,16 +85,6 @@
NUM_CACHE_TYPES, // This must be at the end.
};
- // This is used as a bitmask for the cache state.
- enum CacheState {
- CACHE_STATE_NONE = 0x0,
- CACHE_STATE_PINNED = 0x1 << 0,
- CACHE_STATE_PRESENT = 0x1 << 1,
- CACHE_STATE_DIRTY = 0x1 << 2,
- CACHE_STATE_MOUNTED = 0x1 << 3,
- CACHE_STATE_PERSISTENT = 0x1 << 4,
- };
-
// Enum defining origin of a cached file.
enum CachedFileOrigin {
CACHED_FILE_FROM_SERVER = 0,
@@ -118,98 +116,6 @@
virtual ~Observer() {}
};
- // Structure to store information of an existing cache file.
- class CacheEntry {
- public:
- CacheEntry() : cache_state_(CACHE_STATE_NONE) {}
-
- CacheEntry(const std::string& md5,
- int cache_state)
- : md5_(md5),
- cache_state_(cache_state) {
- }
-
- // The MD5 of the cache file. This can be "local" if the file is
- // locally modified.
- const std::string& md5() const { return md5_; }
-
- // The cache state represented as a bitmask of GDataCacheState.
- int cache_state() const { return cache_state_; }
-
- void set_md5(const std::string& md5) { md5_ = md5; }
- void set_cache_state(int cache_state) { cache_state_ = cache_state; }
-
- // Returns true if the file is present locally.
- bool IsPresent() const { return cache_state_ & CACHE_STATE_PRESENT; }
-
- // Returns true if the file is pinned (i.e. available offline).
- bool IsPinned() const { return cache_state_ & CACHE_STATE_PINNED; }
-
- // Returns true if the file is dirty (i.e. modified locally).
- bool IsDirty() const { return cache_state_ & CACHE_STATE_DIRTY; }
-
- // Returns true if the file is a mounted archive file.
- bool IsMounted() const { return cache_state_ & CACHE_STATE_MOUNTED; }
-
- // Returns true if the file is in the persistent directory.
- bool IsPersistent() const { return cache_state_ & CACHE_STATE_PERSISTENT; }
-
- // Setters for the states describe above.
- void SetPresent(bool value) {
- if (value)
- cache_state_ |= CACHE_STATE_PRESENT;
- else
- cache_state_ &= ~CACHE_STATE_PRESENT;
- }
- void SetPinned(bool value) {
- if (value)
- cache_state_ |= CACHE_STATE_PINNED;
- else
- cache_state_ &= ~CACHE_STATE_PINNED;
- }
- void SetDirty(bool value) {
- if (value)
- cache_state_ |= CACHE_STATE_DIRTY;
- else
- cache_state_ &= ~CACHE_STATE_DIRTY;
- }
- void SetMounted(bool value) {
- if (value)
- cache_state_ |= CACHE_STATE_MOUNTED;
- else
- cache_state_ &= ~CACHE_STATE_MOUNTED;
- }
- void SetPersistent(bool value) {
- if (value)
- cache_state_ |= CACHE_STATE_PERSISTENT;
- else
- cache_state_ &= ~CACHE_STATE_PERSISTENT;
- }
-
- // Returns the type of the sub directory where the cache file is stored.
- CacheSubDirectoryType GetSubDirectoryType() const {
- return IsPersistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP;
- }
-
- // For debugging purposes.
- std::string ToString() const;
-
- private:
- std::string md5_;
- int cache_state_;
- };
-
- // Callback for GetCacheEntryOnUIThread.
- // |success| indicates if the operation was successful.
- // |cache_entry| is the obtained cache entry. On failure, |cache_state| is
- // set to CACHE_STATE_NONE.
- //
- // TODO(satorux): Unlike other callback types, this has to be defined
- // inside GDataCache as CacheEntry is inside GDataCache. We should get them
- // outside of GDataCache.
- typedef base::Callback<void(bool success, const CacheEntry& cache_entry)>
- GetCacheEntryCallback;
-
// Returns the sub-directory under gdata cache directory for the given sub
// directory type. Example: <user_profile_dir>/GCache/v1/tmp
//
@@ -350,8 +256,8 @@
// |md5| can be empty if only matching |resource_id| is desired, which may
// happen when looking for pinned entries where symlinks' filenames have no
// extension and hence no md5.
- scoped_ptr<CacheEntry> GetCacheEntry(const std::string& resource_id,
- const std::string& md5);
+ scoped_ptr<GDataCacheEntry> GetCacheEntry(const std::string& resource_id,
+ const std::string& md5);
// Factory methods for GDataCache.
// |pool| and |sequence_token| are used to assert that the functions are
@@ -383,6 +289,10 @@
static bool CreateCacheDirectories(
const std::vector<FilePath>& paths_to_create);
+ // Returns the type of the sub directory where the cache file is stored.
+ static CacheSubDirectoryType GetSubDirectoryType(
+ const GDataCacheEntry& cache_entry);
+
private:
GDataCache(
const FilePath& cache_root_path,
@@ -485,7 +395,7 @@
void GetCacheEntryHelper(const std::string& resource_id,
const std::string& md5,
bool* success,
- GDataCache::CacheEntry* cache_entry);
+ GDataCacheEntry* cache_entry);
// The root directory of the cache (i.e. <user_profile_dir>/GCache/v1).
const FilePath cache_root_path_;
diff --git a/chrome/browser/chromeos/gdata/gdata_cache_entry.h b/chrome/browser/chromeos/gdata/gdata_cache_entry.h
new file mode 100644
index 0000000..e3c0185
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/gdata_cache_entry.h
@@ -0,0 +1,101 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_ENTRY_H_
+#define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_ENTRY_H_
+
+#include <string>
+
+namespace gdata {
+
+// This is used as a bitmask for the cache state.
+enum GDataCacheState {
+ CACHE_STATE_NONE = 0x0,
+ CACHE_STATE_PINNED = 0x1 << 0,
+ CACHE_STATE_PRESENT = 0x1 << 1,
+ CACHE_STATE_DIRTY = 0x1 << 2,
+ CACHE_STATE_MOUNTED = 0x1 << 3,
+ CACHE_STATE_PERSISTENT = 0x1 << 4,
+};
+
+// Structure to store information of an existing cache file.
+// Cache files are stored in 'tmp' or 'persistent' directory.
+class GDataCacheEntry {
+ public:
+ GDataCacheEntry() : cache_state_(CACHE_STATE_NONE) {}
+
+ GDataCacheEntry(const std::string& md5,
+ int cache_state)
+ : md5_(md5),
+ cache_state_(cache_state) {
+ }
+
+ // The MD5 of the cache file. This can be "local" if the file is
+ // locally modified.
+ const std::string& md5() const { return md5_; }
+
+ // The cache state represented as a bitmask of GDataCacheState.
+ int cache_state() const { return cache_state_; }
+
+ void set_md5(const std::string& md5) { md5_ = md5; }
+ void set_cache_state(int cache_state) { cache_state_ = cache_state; }
+
+ // Returns true if the file is present locally.
+ bool IsPresent() const { return cache_state_ & CACHE_STATE_PRESENT; }
+
+ // Returns true if the file is pinned (i.e. available offline).
+ bool IsPinned() const { return cache_state_ & CACHE_STATE_PINNED; }
+
+ // Returns true if the file is dirty (i.e. modified locally).
+ bool IsDirty() const { return cache_state_ & CACHE_STATE_DIRTY; }
+
+ // Returns true if the file is a mounted archive file.
+ bool IsMounted() const { return cache_state_ & CACHE_STATE_MOUNTED; }
+
+ // Returns true if the file is in the persistent directory.
+ bool IsPersistent() const { return cache_state_ & CACHE_STATE_PERSISTENT; }
+
+ // Setters for the states describe above.
+ void SetPresent(bool value) {
+ if (value)
+ cache_state_ |= CACHE_STATE_PRESENT;
+ else
+ cache_state_ &= ~CACHE_STATE_PRESENT;
+ }
+ void SetPinned(bool value) {
+ if (value)
+ cache_state_ |= CACHE_STATE_PINNED;
+ else
+ cache_state_ &= ~CACHE_STATE_PINNED;
+ }
+ void SetDirty(bool value) {
+ if (value)
+ cache_state_ |= CACHE_STATE_DIRTY;
+ else
+ cache_state_ &= ~CACHE_STATE_DIRTY;
+ }
+ void SetMounted(bool value) {
+ if (value)
+ cache_state_ |= CACHE_STATE_MOUNTED;
+ else
+ cache_state_ &= ~CACHE_STATE_MOUNTED;
+ }
+ void SetPersistent(bool value) {
+ if (value)
+ cache_state_ |= CACHE_STATE_PERSISTENT;
+ else
+ cache_state_ &= ~CACHE_STATE_PERSISTENT;
+ }
+
+ // For debugging purposes.
+ std::string ToString() const;
+
+ private:
+ std::string md5_;
+ int cache_state_;
+};
+
+} // namespace gdata
+
+#endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_ENTRY_H_
diff --git a/chrome/browser/chromeos/gdata/gdata_cache_entry_unittest.cc b/chrome/browser/chromeos/gdata/gdata_cache_entry_unittest.cc
new file mode 100644
index 0000000..ae097ff
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/gdata_cache_entry_unittest.cc
@@ -0,0 +1,96 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/gdata/gdata_cache_entry.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gdata {
+
+TEST(GDataCacheEntryTest, CacheStateChanges) {
+ GDataCacheEntry cache_entry("dummy_md5", CACHE_STATE_NONE);
+ EXPECT_FALSE(cache_entry.IsPresent());
+ EXPECT_FALSE(cache_entry.IsPinned());
+ EXPECT_FALSE(cache_entry.IsDirty());
+ EXPECT_FALSE(cache_entry.IsMounted());
+ EXPECT_FALSE(cache_entry.IsPersistent());
+
+ cache_entry.SetPresent(true);
+ EXPECT_TRUE(cache_entry.IsPresent());
+ EXPECT_FALSE(cache_entry.IsPinned());
+ EXPECT_FALSE(cache_entry.IsDirty());
+ EXPECT_FALSE(cache_entry.IsMounted());
+ EXPECT_FALSE(cache_entry.IsPersistent());
+
+ cache_entry.SetPinned(true);
+ EXPECT_TRUE(cache_entry.IsPresent());
+ EXPECT_TRUE(cache_entry.IsPinned());
+ EXPECT_FALSE(cache_entry.IsDirty());
+ EXPECT_FALSE(cache_entry.IsMounted());
+ EXPECT_FALSE(cache_entry.IsPersistent());
+
+ cache_entry.SetDirty(true);
+ EXPECT_TRUE(cache_entry.IsPresent());
+ EXPECT_TRUE(cache_entry.IsPinned());
+ EXPECT_TRUE(cache_entry.IsDirty());
+ EXPECT_FALSE(cache_entry.IsMounted());
+ EXPECT_FALSE(cache_entry.IsPersistent());
+
+ cache_entry.SetMounted(true);
+ EXPECT_TRUE(cache_entry.IsPresent());
+ EXPECT_TRUE(cache_entry.IsPinned());
+ EXPECT_TRUE(cache_entry.IsDirty());
+ EXPECT_TRUE(cache_entry.IsMounted());
+ EXPECT_FALSE(cache_entry.IsPersistent());
+
+ cache_entry.SetPersistent(true);
+ EXPECT_TRUE(cache_entry.IsPresent());
+ EXPECT_TRUE(cache_entry.IsPinned());
+ EXPECT_TRUE(cache_entry.IsDirty());
+ EXPECT_TRUE(cache_entry.IsMounted());
+ EXPECT_TRUE(cache_entry.IsPersistent());
+
+ cache_entry.SetPresent(false);
+ EXPECT_FALSE(cache_entry.IsPresent());
+ EXPECT_TRUE(cache_entry.IsPinned());
+ EXPECT_TRUE(cache_entry.IsDirty());
+ EXPECT_TRUE(cache_entry.IsMounted());
+ EXPECT_TRUE(cache_entry.IsPersistent());
+
+ cache_entry.SetPresent(false);
+ EXPECT_FALSE(cache_entry.IsPresent());
+ EXPECT_TRUE(cache_entry.IsPinned());
+ EXPECT_TRUE(cache_entry.IsDirty());
+ EXPECT_TRUE(cache_entry.IsMounted());
+ EXPECT_TRUE(cache_entry.IsPersistent());
+
+ cache_entry.SetPinned(false);
+ EXPECT_FALSE(cache_entry.IsPresent());
+ EXPECT_FALSE(cache_entry.IsPinned());
+ EXPECT_TRUE(cache_entry.IsDirty());
+ EXPECT_TRUE(cache_entry.IsMounted());
+ EXPECT_TRUE(cache_entry.IsPersistent());
+
+ cache_entry.SetDirty(false);
+ EXPECT_FALSE(cache_entry.IsPresent());
+ EXPECT_FALSE(cache_entry.IsPinned());
+ EXPECT_FALSE(cache_entry.IsDirty());
+ EXPECT_TRUE(cache_entry.IsMounted());
+ EXPECT_TRUE(cache_entry.IsPersistent());
+
+ cache_entry.SetMounted(false);
+ EXPECT_FALSE(cache_entry.IsPresent());
+ EXPECT_FALSE(cache_entry.IsPinned());
+ EXPECT_FALSE(cache_entry.IsDirty());
+ EXPECT_FALSE(cache_entry.IsMounted());
+ EXPECT_TRUE(cache_entry.IsPersistent());
+
+ cache_entry.SetPersistent(false);
+ EXPECT_FALSE(cache_entry.IsPresent());
+ EXPECT_FALSE(cache_entry.IsPinned());
+ EXPECT_FALSE(cache_entry.IsDirty());
+ EXPECT_FALSE(cache_entry.IsMounted());
+ EXPECT_FALSE(cache_entry.IsPersistent());
+}
+
+} // namespace gdata
diff --git a/chrome/browser/chromeos/gdata/gdata_cache_metadata.cc b/chrome/browser/chromeos/gdata/gdata_cache_metadata.cc
index 8b46a62a..fafcb5f15 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache_metadata.cc
+++ b/chrome/browser/chromeos/gdata/gdata_cache_metadata.cc
@@ -67,7 +67,7 @@
GDataCacheMetadataMap::CacheMap::iterator cache_map_iter =
cache_map->find(resource_id);
if (cache_map_iter != cache_map->end()) {
- const GDataCache::CacheEntry& cache_entry = cache_map_iter->second;
+ const GDataCacheEntry& cache_entry = cache_map_iter->second;
// If the file is dirty but not committed, remove it.
if (cache_entry.IsDirty() && outgoing_file_map.count(resource_id) == 0) {
LOG(WARNING) << "Removing dirty-but-not-committed file: "
@@ -176,21 +176,21 @@
void GDataCacheMetadataMap::UpdateCache(
const std::string& resource_id,
- const GDataCache::CacheEntry& cache_entry) {
+ const GDataCacheEntry& cache_entry) {
AssertOnSequencedWorkerPool();
CacheMap::iterator iter = cache_map_.find(resource_id);
if (iter == cache_map_.end()) { // New resource, create new entry.
// Makes no sense to create new entry if cache state is NONE.
- DCHECK(cache_entry.cache_state() != GDataCache::CACHE_STATE_NONE);
- if (cache_entry.cache_state() != GDataCache::CACHE_STATE_NONE) {
+ DCHECK(cache_entry.cache_state() != CACHE_STATE_NONE);
+ if (cache_entry.cache_state() != CACHE_STATE_NONE) {
cache_map_.insert(std::make_pair(resource_id, cache_entry));
DVLOG(1) << "Added res_id=" << resource_id
<< ", " << cache_entry.ToString();
}
} else { // Resource exists.
// If cache state is NONE, delete entry from cache map.
- if (cache_entry.cache_state() == GDataCache::CACHE_STATE_NONE) {
+ if (cache_entry.cache_state() == CACHE_STATE_NONE) {
DVLOG(1) << "Deleting res_id=" << resource_id
<< ", " << iter->second.ToString();
cache_map_.erase(iter);
@@ -213,7 +213,7 @@
}
}
-scoped_ptr<GDataCache::CacheEntry> GDataCacheMetadataMap::GetCacheEntry(
+scoped_ptr<GDataCacheEntry> GDataCacheMetadataMap::GetCacheEntry(
const std::string& resource_id,
const std::string& md5) {
AssertOnSequencedWorkerPool();
@@ -221,18 +221,18 @@
CacheMap::iterator iter = cache_map_.find(resource_id);
if (iter == cache_map_.end()) {
DVLOG(1) << "Can't find " << resource_id << " in cache map";
- return scoped_ptr<GDataCache::CacheEntry>();
+ return scoped_ptr<GDataCacheEntry>();
}
- scoped_ptr<GDataCache::CacheEntry> cache_entry(
- new GDataCache::CacheEntry(iter->second));
+ scoped_ptr<GDataCacheEntry> cache_entry(
+ new GDataCacheEntry(iter->second));
if (!CheckIfMd5Matches(md5, *cache_entry)) {
DVLOG(1) << "Non-matching md5: want=" << md5
<< ", found=[res_id=" << resource_id
<< ", " << cache_entry->ToString()
<< "]";
- return scoped_ptr<GDataCache::CacheEntry>();
+ return scoped_ptr<GDataCacheEntry>();
}
DVLOG(1) << "Found entry for res_id=" << resource_id
@@ -289,7 +289,7 @@
util::ParseCacheFilePath(current, &resource_id, &md5, &extra_extension);
// Determine cache state.
- GDataCache::CacheEntry cache_entry(md5, GDataCache::CACHE_STATE_NONE);
+ GDataCacheEntry cache_entry(md5, CACHE_STATE_NONE);
// If we're scanning pinned directory and if entry already exists, just
// update its pinned state.
if (sub_dir_type == GDataCache::CACHE_TYPE_PINNED) {
@@ -381,7 +381,7 @@
// static
bool GDataCacheMetadataMap::CheckIfMd5Matches(
const std::string& md5,
- const GDataCache::CacheEntry& cache_entry) {
+ const GDataCacheEntry& cache_entry) {
if (cache_entry.IsDirty()) {
// If the entry is dirty, its MD5 may have been replaced by "local"
// during cache initialization, so we don't compare MD5.
diff --git a/chrome/browser/chromeos/gdata/gdata_cache_metadata.h b/chrome/browser/chromeos/gdata/gdata_cache_metadata.h
index d0bdbcf79..fbcbfc0 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache_metadata.h
+++ b/chrome/browser/chromeos/gdata/gdata_cache_metadata.h
@@ -22,7 +22,7 @@
public:
// Callback for Iterate().
typedef base::Callback<void(const std::string& resource_id,
- const GDataCache::CacheEntry& cache_entry)>
+ const GDataCacheEntry& cache_entry)>
IterateCallback;
// |pool| and |sequence_token| are used to assert that the functions are
@@ -38,7 +38,7 @@
// Updates cache map with entry corresponding to |resource_id|.
// Creates new entry if it doesn't exist, otherwise update the entry.
virtual void UpdateCache(const std::string& resource_id,
- const GDataCache::CacheEntry& cache_entry) = 0;
+ const GDataCacheEntry& cache_entry) = 0;
// Removes entry corresponding to |resource_id| from cache map.
virtual void RemoveFromCache(const std::string& resource_id) = 0;
@@ -48,7 +48,7 @@
// |md5| can be empty if only matching |resource_id| is desired, which may
// happen when looking for pinned entries where symlinks' filenames have no
// extension and hence no md5.
- virtual scoped_ptr<GDataCache::CacheEntry> GetCacheEntry(
+ virtual scoped_ptr<GDataCacheEntry> GetCacheEntry(
const std::string& resource_id,
const std::string& md5) = 0;
@@ -85,16 +85,16 @@
// GDataCacheMetadata overrides:
virtual void UpdateCache(
const std::string& resource_id,
- const GDataCache::CacheEntry& cache_entry) OVERRIDE;
+ const GDataCacheEntry& cache_entry) OVERRIDE;
virtual void RemoveFromCache(const std::string& resource_id) OVERRIDE;
- virtual scoped_ptr<GDataCache::CacheEntry> GetCacheEntry(
+ virtual scoped_ptr<GDataCacheEntry> GetCacheEntry(
const std::string& resource_id,
const std::string& md5) OVERRIDE;
virtual void RemoveTemporaryFiles() OVERRIDE;
virtual void Iterate(const IterateCallback& callback) OVERRIDE;
// A map table of cache file's resource id to its CacheEntry* entry.
- typedef std::map<std::string, GDataCache::CacheEntry> CacheMap;
+ typedef std::map<std::string, GDataCacheEntry> CacheMap;
// A map table of resource ID to file path.
typedef std::map<std::string, FilePath> ResourceIdToFilePathMap;
@@ -117,7 +117,7 @@
// Returns true if |md5| matches the one in |cache_entry| with some
// exceptions. See the function definition for details.
static bool CheckIfMd5Matches(const std::string& md5,
- const GDataCache::CacheEntry& cache_entry);
+ const GDataCacheEntry& cache_entry);
CacheMap cache_map_;
diff --git a/chrome/browser/chromeos/gdata/gdata_cache_metadata_unittest.cc b/chrome/browser/chromeos/gdata/gdata_cache_metadata_unittest.cc
index 4fada510..7bc149a 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache_metadata_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_cache_metadata_unittest.cc
@@ -118,7 +118,7 @@
const std::string& md5,
int cache_state) {
cache_map->insert(std::make_pair(
- resource_id, GDataCache::CacheEntry(md5, cache_state)));
+ resource_id, GDataCacheEntry(md5, cache_state)));
}
ScopedTempDir temp_dir_;
@@ -140,18 +140,18 @@
std::string test_file_md5("test_file_md5");
GDataCache::CacheSubDirectoryType test_sub_dir_type =
GDataCache::CACHE_TYPE_PERSISTENT;
- int test_cache_state = (GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PERSISTENT);
+ int test_cache_state = (CACHE_STATE_PRESENT |
+ CACHE_STATE_PERSISTENT);
metadata_->UpdateCache(
test_resource_id,
- GDataCache::CacheEntry(test_file_md5, test_cache_state));
+ GDataCacheEntry(test_file_md5, test_cache_state));
// Test that the entry can be retrieved.
- scoped_ptr<GDataCache::CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
metadata_->GetCacheEntry(test_resource_id, test_file_md5);
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ(test_file_md5, cache_entry->md5());
- EXPECT_EQ(test_sub_dir_type, cache_entry->GetSubDirectoryType());
+ EXPECT_EQ(test_sub_dir_type, GDataCache::GetSubDirectoryType(*cache_entry));
EXPECT_EQ(test_cache_state, cache_entry->cache_state());
// Empty md5 should also work.
@@ -173,17 +173,17 @@
// Update all attributes.
test_file_md5 = "test_file_md5_2";
test_sub_dir_type = GDataCache::CACHE_TYPE_TMP;
- test_cache_state = GDataCache::CACHE_STATE_PINNED;
+ test_cache_state = CACHE_STATE_PINNED;
metadata_->UpdateCache(
test_resource_id,
- GDataCache::CacheEntry(test_file_md5, test_cache_state));
+ GDataCacheEntry(test_file_md5, test_cache_state));
// Make sure the values took.
cache_entry =
metadata_->GetCacheEntry(test_resource_id, test_file_md5).Pass();
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ(test_file_md5, cache_entry->md5());
- EXPECT_EQ(test_sub_dir_type, cache_entry->GetSubDirectoryType());
+ EXPECT_EQ(test_sub_dir_type, GDataCache::GetSubDirectoryType(*cache_entry));
EXPECT_EQ(test_cache_state, cache_entry->cache_state());
// Empty m5 should work.
@@ -195,17 +195,17 @@
// Test dirty cache.
test_file_md5 = "test_file_md5_3";
test_sub_dir_type = GDataCache::CACHE_TYPE_TMP;
- test_cache_state = GDataCache::CACHE_STATE_DIRTY;
+ test_cache_state = CACHE_STATE_DIRTY;
metadata_->UpdateCache(
test_resource_id,
- GDataCache::CacheEntry(test_file_md5, test_cache_state));
+ GDataCacheEntry(test_file_md5, test_cache_state));
// Make sure the values took.
cache_entry =
metadata_->GetCacheEntry(test_resource_id, test_file_md5).Pass();
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ(test_file_md5, cache_entry->md5());
- EXPECT_EQ(test_sub_dir_type, cache_entry->GetSubDirectoryType());
+ EXPECT_EQ(test_sub_dir_type, GDataCache::GetSubDirectoryType(*cache_entry));
EXPECT_EQ(test_cache_state, cache_entry->cache_state());
// Empty md5 should work.
@@ -230,26 +230,26 @@
test_resource_id = "test_resource_id_2";
test_file_md5 = "test_file_md5_4";
test_sub_dir_type = GDataCache::CACHE_TYPE_TMP;
- test_cache_state = GDataCache::CACHE_STATE_PRESENT;
+ test_cache_state = CACHE_STATE_PRESENT;
metadata_->UpdateCache(
test_resource_id,
- GDataCache::CacheEntry(test_file_md5, test_cache_state));
+ GDataCacheEntry(test_file_md5, test_cache_state));
// Make sure the values took.
cache_entry =
metadata_->GetCacheEntry(test_resource_id, test_file_md5).Pass();
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ(test_file_md5, cache_entry->md5());
- EXPECT_EQ(test_sub_dir_type, cache_entry->GetSubDirectoryType());
+ EXPECT_EQ(test_sub_dir_type, GDataCache::GetSubDirectoryType(*cache_entry));
EXPECT_EQ(test_cache_state, cache_entry->cache_state());
// Update with CACHE_STATE_NONE should evict the entry.
test_file_md5 = "test_file_md5_5";
test_sub_dir_type = GDataCache::CACHE_TYPE_TMP;
- test_cache_state = GDataCache::CACHE_STATE_NONE;
+ test_cache_state = CACHE_STATE_NONE;
metadata_->UpdateCache(
test_resource_id,
- GDataCache::CacheEntry(test_file_md5, test_cache_state));
+ GDataCacheEntry(test_file_md5, test_cache_state));
cache_entry =
metadata_->GetCacheEntry(test_resource_id, std::string()).Pass();
@@ -278,14 +278,14 @@
// Check contents in "persistent" directory.
//
// "id_foo" is present and pinned.
- scoped_ptr<GDataCache::CacheEntry> cache_entry;
+ scoped_ptr<GDataCacheEntry> cache_entry;
cache_entry = metadata_->GetCacheEntry("id_foo", "md5foo");
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ("md5foo", cache_entry->md5());
EXPECT_EQ(GDataCache::CACHE_TYPE_PERSISTENT,
- cache_entry->GetSubDirectoryType());
- EXPECT_EQ(GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ GDataCache::GetSubDirectoryType(*cache_entry));
+ EXPECT_EQ(CACHE_STATE_PRESENT | CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
cache_entry->cache_state());
EXPECT_TRUE(PathExists(persistent_directory_.AppendASCII("id_foo.md5foo")));
EXPECT_TRUE(PathExists(pinned_directory_.AppendASCII("id_foo")));
@@ -297,9 +297,9 @@
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ("local", cache_entry->md5());
EXPECT_EQ(GDataCache::CACHE_TYPE_PERSISTENT,
- cache_entry->GetSubDirectoryType());
- EXPECT_EQ(GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ GDataCache::GetSubDirectoryType(*cache_entry));
+ EXPECT_EQ(CACHE_STATE_PRESENT | CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
cache_entry->cache_state());
EXPECT_TRUE(PathExists(persistent_directory_.AppendASCII("id_bar.local")));
EXPECT_TRUE(PathExists(outgoing_directory_.AppendASCII("id_bar")));
@@ -325,8 +325,9 @@
cache_entry = metadata_->GetCacheEntry("id_qux", "md5qux");
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ("md5qux", cache_entry->md5());
- EXPECT_EQ(GDataCache::CACHE_TYPE_TMP, cache_entry->GetSubDirectoryType());
- EXPECT_EQ(GDataCache::CACHE_STATE_PRESENT, cache_entry->cache_state());
+ EXPECT_EQ(GDataCache::CACHE_TYPE_TMP,
+ GDataCache::GetSubDirectoryType(*cache_entry));
+ EXPECT_EQ(CACHE_STATE_PRESENT, cache_entry->cache_state());
EXPECT_TRUE(PathExists(tmp_directory_.AppendASCII("id_qux.md5qux")));
// "id_quux" should be removed during cache initialization.
@@ -345,7 +346,7 @@
cache_entry = metadata_->GetCacheEntry("id_corge", "");
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ("", cache_entry->md5());
- EXPECT_EQ(GDataCache::CACHE_STATE_PINNED, cache_entry->cache_state());
+ EXPECT_EQ(CACHE_STATE_PINNED, cache_entry->cache_state());
EXPECT_TRUE(IsLink(pinned_directory_.AppendASCII("id_corge")));
// "id_dangling" should be removed during cache initialization.
@@ -372,21 +373,21 @@
InsertIntoMap(&cache_map,
"<resource_id_1>",
"<md5>",
- GDataCache::CACHE_STATE_PRESENT);
+ CACHE_STATE_PRESENT);
InsertIntoMap(&cache_map,
"<resource_id_2>",
"<md5>",
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PERSISTENT);
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PERSISTENT);
InsertIntoMap(&cache_map,
"<resource_id_3>",
"<md5>",
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PERSISTENT);
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PERSISTENT);
InsertIntoMap(&cache_map,
"<resource_id_4>",
"<md5>",
- GDataCache::CACHE_STATE_PRESENT);
+ CACHE_STATE_PRESENT);
metadata_->cache_map_ = cache_map;
metadata_->RemoveTemporaryFiles();
diff --git a/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc b/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
index 5f6f7fa..eb59f93 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
@@ -39,42 +39,42 @@
} const initial_cache_resources[] = {
// Cache resource in tmp dir, i.e. not pinned or dirty.
{ "root_feed.json", "tmp:resource_id", "md5_tmp_alphanumeric",
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
"md5_tmp_alphanumeric", GDataCache::CACHE_TYPE_TMP },
// Cache resource in tmp dir, i.e. not pinned or dirty, with resource_id
// containing non-alphanumeric characters, to test resource_id is escaped and
// unescaped correctly.
{ "subdir_feed.json", "tmp:`~!@#$%^&*()-_=+[{|]}\\;',<.>/?",
"md5_tmp_non_alphanumeric",
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
"md5_tmp_non_alphanumeric", GDataCache::CACHE_TYPE_TMP },
// Cache resource that is pinned, to test a pinned file is in persistent dir
// with a symlink in pinned dir referencing it.
{ "directory_entry_atom.json", "pinned:existing", "md5_pinned_existing",
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
"md5_pinned_existing", GDataCache::CACHE_TYPE_PERSISTENT },
// Cache resource with a non-existent source file that is pinned, to test that
// a pinned file can reference a non-existent file.
{ "", "pinned:non-existent", "md5_pinned_non_existent",
- GDataCache::CACHE_STATE_PINNED,
+ CACHE_STATE_PINNED,
"md5_pinned_non_existent", GDataCache::CACHE_TYPE_TMP },
// Cache resource that is dirty, to test a dirty file is in persistent dir
// with a symlink in outgoing dir referencing it.
{ "account_metadata.json", "dirty:existing", "md5_dirty_existing",
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
"local", GDataCache::CACHE_TYPE_PERSISTENT },
// Cache resource that is pinned and dirty, to test a dirty pinned file is in
// persistent dir with symlink in pinned and outgoing dirs referencing it.
{ "basic_feed.json", "dirty_and_pinned:existing",
"md5_dirty_and_pinned_existing",
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
"local", GDataCache::CACHE_TYPE_PERSISTENT },
};
@@ -91,9 +91,9 @@
FilePath expected_existing_path;
};
-// Converts |cache_state| to a GDataCache::CacheEntry.
-GDataCache::CacheEntry ToCacheEntry(int cache_state) {
- return GDataCache::CacheEntry("dummy_md5", cache_state);
+// Converts |cache_state| to a GDataCacheEntry.
+GDataCacheEntry ToCacheEntry(int cache_state) {
+ return GDataCacheEntry("dummy_md5", cache_state);
}
} // namespace
@@ -337,12 +337,12 @@
std::string md5;
if (ToCacheEntry(resource.cache_state).IsPresent())
md5 = resource.md5;
- scoped_ptr<GDataCache::CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntryFromOriginThread(resource.resource_id, md5);
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ(resource.cache_state, cache_entry->cache_state());
EXPECT_EQ(resource.expected_sub_dir_type,
- cache_entry->GetSubDirectoryType());
+ GDataCache::GetSubDirectoryType(*cache_entry));
}
}
@@ -424,7 +424,7 @@
EXPECT_EQ(expected_error_, error);
// Verify cache map.
- scoped_ptr<GDataCache::CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntryFromOriginThread(resource_id, md5);
if (cache_entry.get())
EXPECT_TRUE(cache_entry->IsDirty());
@@ -564,7 +564,7 @@
}
void VerifyGetCacheState(bool success,
- const GDataCache::CacheEntry& cache_entry) {
+ const GDataCacheEntry& cache_entry) {
++num_callback_invocations_;
EXPECT_EQ(expected_success_, success);
@@ -692,13 +692,14 @@
EXPECT_EQ(expected_error_, error);
// Verify cache map.
- scoped_ptr<GDataCache::CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntryFromOriginThread(resource_id, md5);
if (ToCacheEntry(expected_cache_state_).IsPresent() ||
ToCacheEntry(expected_cache_state_).IsPinned()) {
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ(expected_cache_state_, cache_entry->cache_state());
- EXPECT_EQ(expected_sub_dir_type_, cache_entry->GetSubDirectoryType());
+ EXPECT_EQ(expected_sub_dir_type_,
+ GDataCache::GetSubDirectoryType(*cache_entry));
} else {
EXPECT_FALSE(cache_entry.get());
}
@@ -770,10 +771,10 @@
}
// Helper function to call GetCacheEntry from origin thread.
- scoped_ptr<GDataCache::CacheEntry> GetCacheEntryFromOriginThread(
+ scoped_ptr<GDataCacheEntry> GetCacheEntryFromOriginThread(
const std::string& resource_id,
const std::string& md5) {
- scoped_ptr<GDataCache::CacheEntry> cache_entry;
+ scoped_ptr<GDataCacheEntry> cache_entry;
content::BrowserThread::GetBlockingPool()
->GetSequencedTaskRunner(sequence_token_)->PostTask(
FROM_HERE,
@@ -791,7 +792,7 @@
void GetCacheEntryFromOriginThreadInternal(
const std::string& resource_id,
const std::string& md5,
- scoped_ptr<GDataCache::CacheEntry>* cache_entry) {
+ scoped_ptr<GDataCacheEntry>* cache_entry) {
cache_entry->reset(cache_->GetCacheEntry(resource_id, md5).release());
}
@@ -878,92 +879,6 @@
TestInitializeCache();
}
-TEST_F(GDataCacheTest, CacheEntry_CacheStateChanges) {
- GDataCache::CacheEntry cache_entry("dummy_md5", GDataCache::CACHE_STATE_NONE);
- EXPECT_FALSE(cache_entry.IsPresent());
- EXPECT_FALSE(cache_entry.IsPinned());
- EXPECT_FALSE(cache_entry.IsDirty());
- EXPECT_FALSE(cache_entry.IsMounted());
- EXPECT_FALSE(cache_entry.IsPersistent());
-
- cache_entry.SetPresent(true);
- EXPECT_TRUE(cache_entry.IsPresent());
- EXPECT_FALSE(cache_entry.IsPinned());
- EXPECT_FALSE(cache_entry.IsDirty());
- EXPECT_FALSE(cache_entry.IsMounted());
- EXPECT_FALSE(cache_entry.IsPersistent());
-
- cache_entry.SetPinned(true);
- EXPECT_TRUE(cache_entry.IsPresent());
- EXPECT_TRUE(cache_entry.IsPinned());
- EXPECT_FALSE(cache_entry.IsDirty());
- EXPECT_FALSE(cache_entry.IsMounted());
- EXPECT_FALSE(cache_entry.IsPersistent());
-
- cache_entry.SetDirty(true);
- EXPECT_TRUE(cache_entry.IsPresent());
- EXPECT_TRUE(cache_entry.IsPinned());
- EXPECT_TRUE(cache_entry.IsDirty());
- EXPECT_FALSE(cache_entry.IsMounted());
- EXPECT_FALSE(cache_entry.IsPersistent());
-
- cache_entry.SetMounted(true);
- EXPECT_TRUE(cache_entry.IsPresent());
- EXPECT_TRUE(cache_entry.IsPinned());
- EXPECT_TRUE(cache_entry.IsDirty());
- EXPECT_TRUE(cache_entry.IsMounted());
- EXPECT_FALSE(cache_entry.IsPersistent());
-
- cache_entry.SetPersistent(true);
- EXPECT_TRUE(cache_entry.IsPresent());
- EXPECT_TRUE(cache_entry.IsPinned());
- EXPECT_TRUE(cache_entry.IsDirty());
- EXPECT_TRUE(cache_entry.IsMounted());
- EXPECT_TRUE(cache_entry.IsPersistent());
-
- cache_entry.SetPresent(false);
- EXPECT_FALSE(cache_entry.IsPresent());
- EXPECT_TRUE(cache_entry.IsPinned());
- EXPECT_TRUE(cache_entry.IsDirty());
- EXPECT_TRUE(cache_entry.IsMounted());
- EXPECT_TRUE(cache_entry.IsPersistent());
-
- cache_entry.SetPresent(false);
- EXPECT_FALSE(cache_entry.IsPresent());
- EXPECT_TRUE(cache_entry.IsPinned());
- EXPECT_TRUE(cache_entry.IsDirty());
- EXPECT_TRUE(cache_entry.IsMounted());
- EXPECT_TRUE(cache_entry.IsPersistent());
-
- cache_entry.SetPinned(false);
- EXPECT_FALSE(cache_entry.IsPresent());
- EXPECT_FALSE(cache_entry.IsPinned());
- EXPECT_TRUE(cache_entry.IsDirty());
- EXPECT_TRUE(cache_entry.IsMounted());
- EXPECT_TRUE(cache_entry.IsPersistent());
-
- cache_entry.SetDirty(false);
- EXPECT_FALSE(cache_entry.IsPresent());
- EXPECT_FALSE(cache_entry.IsPinned());
- EXPECT_FALSE(cache_entry.IsDirty());
- EXPECT_TRUE(cache_entry.IsMounted());
- EXPECT_TRUE(cache_entry.IsPersistent());
-
- cache_entry.SetMounted(false);
- EXPECT_FALSE(cache_entry.IsPresent());
- EXPECT_FALSE(cache_entry.IsPinned());
- EXPECT_FALSE(cache_entry.IsDirty());
- EXPECT_FALSE(cache_entry.IsMounted());
- EXPECT_TRUE(cache_entry.IsPersistent());
-
- cache_entry.SetPersistent(false);
- EXPECT_FALSE(cache_entry.IsPresent());
- EXPECT_FALSE(cache_entry.IsPinned());
- EXPECT_FALSE(cache_entry.IsDirty());
- EXPECT_FALSE(cache_entry.IsMounted());
- EXPECT_FALSE(cache_entry.IsPersistent());
-}
-
TEST_F(GDataCacheTest, GetCacheFilePath) {
// Use alphanumeric characters for resource id.
std::string resource_id("pdf:1a2b");
@@ -991,7 +906,7 @@
// Store an existing file.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
@@ -999,7 +914,7 @@
num_callback_invocations_ = 0;
TestStoreToCache(resource_id, md5, FilePath("./non_existent.json"),
base::PLATFORM_FILE_ERROR_NOT_FOUND,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
@@ -1008,7 +923,7 @@
md5 = "new_md5";
num_callback_invocations_ = 0;
TestStoreToCache(resource_id, md5, GetTestFilePath("subdir_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
@@ -1040,7 +955,7 @@
std::string md5("abcdef0123456789");
// First store a file to cache.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Then try to get the existing file from cache.
@@ -1071,7 +986,7 @@
std::string md5("abcdef0123456789");
// First store a file to cache.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Then try to remove existing file from cache.
@@ -1083,7 +998,7 @@
// which is an extension separator.
resource_id = "pdf:`~!@#$%^&*()-_=+[{|]}\\;',<.>/?";
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
num_callback_invocations_ = 0;
@@ -1102,29 +1017,29 @@
// First store a file to cache.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Pin the existing file in cache.
num_callback_invocations_ = 0;
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT | CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Unpin the existing file in cache.
num_callback_invocations_ = 0;
TestUnpin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
// Pin back the same existing file in cache.
num_callback_invocations_ = 0;
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT | CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
@@ -1135,14 +1050,14 @@
num_callback_invocations_ = 0;
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PINNED,
+ CACHE_STATE_PINNED,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
// Unpin the previously pinned non-existent file in cache.
num_callback_invocations_ = 0;
TestUnpin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_NONE,
+ CACHE_STATE_NONE,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
@@ -1154,7 +1069,7 @@
num_callback_invocations_ = 0;
TestUnpin(resource_id, md5, base::PLATFORM_FILE_ERROR_NOT_FOUND,
- GDataCache::CACHE_STATE_NONE,
+ CACHE_STATE_NONE,
GDataCache::CACHE_TYPE_TMP /* non-applicable */);
EXPECT_EQ(1, num_callback_invocations_);
}
@@ -1166,16 +1081,16 @@
// Pin a non-existent file.
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PINNED,
+ CACHE_STATE_PINNED,
GDataCache::CACHE_TYPE_TMP);
// Store an existing file to a previously pinned file.
num_callback_invocations_ = 0;
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
@@ -1183,9 +1098,9 @@
num_callback_invocations_ = 0;
TestStoreToCache(resource_id, md5, FilePath("./non_existent.json"),
base::PLATFORM_FILE_ERROR_NOT_FOUND,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
}
@@ -1197,7 +1112,7 @@
// Pin a non-existent file.
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PINNED,
+ CACHE_STATE_PINNED,
GDataCache::CACHE_TYPE_TMP);
// Get the non-existent pinned file from cache.
@@ -1209,9 +1124,9 @@
// Store an existing file to the previously pinned non-existent file.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
// Get the previously pinned and stored file from cache.
@@ -1229,11 +1144,11 @@
// Store a file to cache, and pin it.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT | CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
// Remove |resource_id| from cache.
@@ -1247,11 +1162,11 @@
EXPECT_CALL(*mock_sync_client_, OnCachePinned(resource_id, md5)).Times(1);
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT | CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
num_callback_invocations_ = 0;
@@ -1266,31 +1181,31 @@
// First store a file to cache.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Mark the file dirty.
num_callback_invocations_ = 0;
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Commit the file dirty.
num_callback_invocations_ = 0;
TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Clear dirty state of the file.
num_callback_invocations_ = 0;
TestClearDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
}
@@ -1303,39 +1218,39 @@
// First store a file to cache and pin it.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT | CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
// Mark the file dirty.
num_callback_invocations_ = 0;
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Commit the file dirty.
num_callback_invocations_ = 0;
TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Clear dirty state of the file.
num_callback_invocations_ = 0;
TestClearDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
}
@@ -1352,12 +1267,12 @@
// First store a file to cache and mark it as dirty.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
// Verifies dirty file exists.
@@ -1370,8 +1285,8 @@
// Pin the dirty file.
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PINNED | GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT | CACHE_STATE_DIRTY |
+ CACHE_STATE_PINNED | CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
// Verify dirty file still exist at the same pathname.
@@ -1379,8 +1294,8 @@
// Unpin the dirty file.
TestUnpin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT | CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
// Verify dirty file still exist at the same pathname.
@@ -1394,42 +1309,42 @@
// First store a file to cache.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Mark the file dirty.
num_callback_invocations_ = 0;
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Again, mark the file dirty. Nothing should change.
num_callback_invocations_ = 0;
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Commit the file dirty. Outgoing symlink should be created.
num_callback_invocations_ = 0;
TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Again, commit the file dirty. Nothing should change.
num_callback_invocations_ = 0;
TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
@@ -1437,32 +1352,32 @@
// should be deleted.
num_callback_invocations_ = 0;
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Commit the file dirty. Outgoing symlink should be created again.
num_callback_invocations_ = 0;
TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
// Clear dirty state of the file.
num_callback_invocations_ = 0;
TestClearDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
// Again, clear dirty state of the file, which is no longer dirty.
num_callback_invocations_ = 0;
TestClearDirty(resource_id, md5, base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
}
@@ -1474,57 +1389,57 @@
// Mark a non-existent file dirty.
num_callback_invocations_ = 0;
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_ERROR_NOT_FOUND,
- GDataCache::CACHE_STATE_NONE,
+ CACHE_STATE_NONE,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
// Commit a non-existent file dirty.
num_callback_invocations_ = 0;
TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_ERROR_NOT_FOUND,
- GDataCache::CACHE_STATE_NONE,
+ CACHE_STATE_NONE,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
// Clear dirty state of a non-existent file.
num_callback_invocations_ = 0;
TestClearDirty(resource_id, md5, base::PLATFORM_FILE_ERROR_NOT_FOUND,
- GDataCache::CACHE_STATE_NONE,
+ CACHE_STATE_NONE,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
// Store a file to cache.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Commit a non-dirty existing file dirty.
num_callback_invocations_ = 0;
TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
// Clear dirty state of a non-dirty existing file.
num_callback_invocations_ = 0;
TestClearDirty(resource_id, md5, base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
// Mark an existing file dirty, then store a new file to the same resource id
// but different md5, which should fail.
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
num_callback_invocations_ = 0;
md5 = "new_md5";
TestStoreToCache(resource_id, md5, GetTestFilePath("subdir_feed.json"),
base::PLATFORM_FILE_ERROR_IN_USE,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
}
@@ -1537,23 +1452,23 @@
// Store a file to cache, pin it, mark it dirty and commit it.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
TestPin(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT | GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT | CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
TestMarkDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
TestCommitDirty(resource_id, md5, base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
// Try to remove the file. Since file is dirty, it and the corresponding
@@ -1579,13 +1494,13 @@
// Store a file corresponding to |resource_id| and |md5| to cache.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Get its cache state.
num_callback_invocations_ = 0;
TestGetCacheState(resource_id, md5, true,
- GDataCache::CACHE_STATE_PRESENT, file);
+ CACHE_STATE_PRESENT, file);
EXPECT_EQ(1, num_callback_invocations_);
}
@@ -1604,11 +1519,11 @@
// Store a file corresponding to |resource_id| and |md5| to cache, and pin
// it.
- int expected_cache_state = (GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT);
+ int expected_cache_state = (CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT);
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
TestPin(resource_id, md5, base::PLATFORM_FILE_OK, expected_cache_state,
GDataCache::CACHE_TYPE_PERSISTENT);
@@ -1635,7 +1550,7 @@
// First store a file to cache in the tmp subdir.
TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
- base::PLATFORM_FILE_OK, GDataCache::CACHE_STATE_PRESENT,
+ base::PLATFORM_FILE_OK, CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Mark the file mounted.
@@ -1645,9 +1560,9 @@
GDataCache::CACHED_FILE_FROM_SERVER);
TestSetMountedState(resource_id, md5, file_path, true,
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_MOUNTED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_MOUNTED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
EXPECT_EQ(1, num_callback_invocations_);
EXPECT_TRUE(CacheEntryExists(resource_id, md5));
@@ -1660,7 +1575,7 @@
GDataCache::CACHED_FILE_MOUNTED);
TestSetMountedState(resource_id, md5, file_path, false,
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
EXPECT_EQ(1, num_callback_invocations_);
EXPECT_TRUE(CacheEntryExists(resource_id, md5));
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index 9901aee..cc559bf 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -2963,7 +2963,7 @@
const std::string& resource_id,
const std::string& md5,
bool success,
- const GDataCache::CacheEntry& cache_entry) {
+ const GDataCacheEntry& cache_entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// TODO(hshi): http://crbug.com/127138 notify when file properties change.
// This allows file manager to clear the "Available offline" checkbox.
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.h b/chrome/browser/chromeos/gdata/gdata_file_system.h
index 923eede..160e422 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.h
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.h
@@ -881,7 +881,7 @@
void UnpinIfPinned(const std::string& resource_id,
const std::string& md5,
bool success,
- const GDataCache::CacheEntry& cache_entry);
+ const GDataCacheEntry& cache_entry);
// Similar to OnFileDownloaded() but takes |has_enough_space| so we report
// an error in case we don't have enough disk space.
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
index deb458f9..9cd2b97 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
@@ -122,9 +122,9 @@
return kUploadId;
}
-// Converts |cache_state| to a GDataCache::CacheEntry.
-GDataCache::CacheEntry ToCacheEntry(int cache_state) {
- return GDataCache::CacheEntry("dummy_md5", cache_state);
+// Converts |cache_state| to a GDataCacheEntry.
+GDataCacheEntry ToCacheEntry(int cache_state) {
+ return GDataCacheEntry("dummy_md5", cache_state);
}
} // namespace
@@ -420,10 +420,10 @@
}
// Helper function to call GetCacheEntry from origin thread.
- scoped_ptr<GDataCache::CacheEntry> GetCacheEntryFromOriginThread(
+ scoped_ptr<GDataCacheEntry> GetCacheEntryFromOriginThread(
const std::string& resource_id,
const std::string& md5) {
- scoped_ptr<GDataCache::CacheEntry> cache_entry;
+ scoped_ptr<GDataCacheEntry> cache_entry;
content::BrowserThread::GetBlockingPool()
->GetSequencedTaskRunner(sequence_token_)->PostTask(
FROM_HERE,
@@ -441,7 +441,7 @@
void GetCacheEntryFromOriginThreadInternal(
const std::string& resource_id,
const std::string& md5,
- scoped_ptr<GDataCache::CacheEntry>* cache_entry) {
+ scoped_ptr<GDataCacheEntry>* cache_entry) {
cache_entry->reset(cache_->GetCacheEntry(resource_id, md5).release());
}
@@ -502,7 +502,7 @@
EXPECT_EQ(expected_error_, error);
// Verify cache map.
- scoped_ptr<GDataCache::CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntryFromOriginThread(resource_id, md5);
if (cache_entry.get())
EXPECT_TRUE(cache_entry->IsDirty());
@@ -671,9 +671,9 @@
const std::string& md5,
const FilePath& cache_file_path) {
expected_error_ = base::PLATFORM_FILE_OK;
- expected_cache_state_ = (GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT);
+ expected_cache_state_ = (CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT);
expected_sub_dir_type_ = GDataCache::CACHE_TYPE_PERSISTENT;
expect_outgoing_symlink_ = false;
VerifyMarkDirty(error, resource_id, md5, cache_file_path);
@@ -686,9 +686,9 @@
const std::string& resource_id,
const std::string& md5) {
expected_error_ = base::PLATFORM_FILE_OK;
- expected_cache_state_ = (GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT);
+ expected_cache_state_ = (CACHE_STATE_PRESENT |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT);
expected_sub_dir_type_ = GDataCache::CACHE_TYPE_PERSISTENT;
expect_outgoing_symlink_ = true;
VerifyCacheFileState(error, resource_id, md5);
@@ -702,13 +702,14 @@
EXPECT_EQ(expected_error_, error);
// Verify cache map.
- scoped_ptr<GDataCache::CacheEntry> cache_entry =
+ scoped_ptr<GDataCacheEntry> cache_entry =
GetCacheEntryFromOriginThread(resource_id, md5);
if (ToCacheEntry(expected_cache_state_).IsPresent() ||
ToCacheEntry(expected_cache_state_).IsPinned()) {
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ(expected_cache_state_, cache_entry->cache_state());
- EXPECT_EQ(expected_sub_dir_type_, cache_entry->GetSubDirectoryType());
+ EXPECT_EQ(expected_sub_dir_type_,
+ GDataCache::GetSubDirectoryType(*cache_entry));
} else {
EXPECT_FALSE(cache_entry.get());
}
@@ -2145,7 +2146,7 @@
"<md5>",
GetTestFilePath("root_feed.json"),
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
ASSERT_TRUE(CacheEntryExists("<resource_id>", "<md5>"));
ASSERT_TRUE(CacheFileExists("<resource_id>", "<md5>"));
@@ -2239,7 +2240,7 @@
file->file_md5(),
GetTestFilePath("root_feed.json"),
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// Make sure we don't fetch metadata for downloading file.
@@ -2339,7 +2340,7 @@
file->file_md5(),
GetTestFilePath("root_feed.json"),
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT,
+ CACHE_STATE_PRESENT,
GDataCache::CACHE_TYPE_TMP);
// The file is obtained from the cache.
@@ -2369,7 +2370,7 @@
TestPin(kResourceId,
kMd5,
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PINNED,
+ CACHE_STATE_PINNED,
GDataCache::CACHE_TYPE_TMP);
// First store a file to cache. A cache file will be created at:
@@ -2382,9 +2383,9 @@
kMd5,
GetTestFilePath("root_feed.json"), // Anything works.
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
ASSERT_TRUE(file_util::PathExists(original_cache_file_path));
@@ -2393,10 +2394,10 @@
TestMarkDirty(kResourceId,
kMd5,
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
const FilePath dirty_cache_file_path =
GDataCache::GetCacheRootPath(profile_.get())
@@ -2412,10 +2413,10 @@
TestCommitDirty(kResourceId,
kMd5,
base::PLATFORM_FILE_OK,
- GDataCache::CACHE_STATE_PRESENT |
- GDataCache::CACHE_STATE_PINNED |
- GDataCache::CACHE_STATE_DIRTY |
- GDataCache::CACHE_STATE_PERSISTENT,
+ CACHE_STATE_PRESENT |
+ CACHE_STATE_PINNED |
+ CACHE_STATE_DIRTY |
+ CACHE_STATE_PERSISTENT,
GDataCache::CACHE_TYPE_PERSISTENT);
const FilePath outgoing_symlink_path =
GDataCache::GetCacheRootPath(profile_.get())
diff --git a/chrome/browser/chromeos/gdata/gdata_sync_client.cc b/chrome/browser/chromeos/gdata/gdata_sync_client.cc
index d4cb7c3..2c12854 100644
--- a/chrome/browser/chromeos/gdata/gdata_sync_client.cc
+++ b/chrome/browser/chromeos/gdata/gdata_sync_client.cc
@@ -345,7 +345,7 @@
const std::string& resource_id,
const std::string& latest_md5,
bool success,
- const GDataCache::CacheEntry& cache_entry) {
+ const GDataCacheEntry& cache_entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!success) {
diff --git a/chrome/browser/chromeos/gdata/gdata_sync_client.h b/chrome/browser/chromeos/gdata/gdata_sync_client.h
index af559cb..0370ccc 100644
--- a/chrome/browser/chromeos/gdata/gdata_sync_client.h
+++ b/chrome/browser/chromeos/gdata/gdata_sync_client.h
@@ -160,7 +160,7 @@
void OnGetCacheEntry(const std::string& resource_id,
const std::string& latest_md5,
bool success,
- const GDataCache::CacheEntry& cache_entry);
+ const GDataCacheEntry& cache_entry);
// Called when an existing cache entry and the local files are removed.
void OnRemove(base::PlatformFileError error,