Merge lp:~osomon/oxide/simple-cache-backend into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 1037
Proposed branch: lp:~osomon/oxide/simple-cache-backend
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 93 lines (+19/-15)
1 file modified
shared/browser/oxide_browser_context.cc (+19/-15)
To merge this branch: bzr merge lp:~osomon/oxide/simple-cache-backend
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+254703@code.launchpad.net

Commit message

Use the simple backend for network and application caches.

To post a comment you must log in.
1015. By Olivier Tilloy

No need for a patch.

1016. By Olivier Tilloy

Create a new network cache in a different place.

1017. By Olivier Tilloy

Use available constant for app cache directory name.

1018. By Olivier Tilloy

Clear the app cache on the FILE thread.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

I think this mostly looks ok - the only thing I am concerned about is that clearing the appcache might be racey. So we can get this in to 1.7, I wonder whether we should just switch the network cache for now (given that's the problematic one) and then look at the application cache in 1.8. WDYT?

1019. By Olivier Tilloy

Revert the changes to the app cache for now.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Yeah, let’s switch only the network cache for now. I updated the MR to revert the appcache changes.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks, this looks fine

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'shared/browser/oxide_browser_context.cc'
2--- shared/browser/oxide_browser_context.cc 2015-03-31 16:47:42 +0000
3+++ shared/browser/oxide_browser_context.cc 2015-04-15 17:01:35 +0000
4@@ -85,7 +85,11 @@
5
6 base::LazyInstance<std::vector<BrowserContext *> > g_all_contexts;
7
8+// Cache was used for the default blockfile backend (CACHE_BACKEND_BLOCKFILE),
9+// Cache2 is used since the switch to the simple backend (CACHE_BACKEND_SIMPLE).
10 const base::FilePath::CharType kCacheDirname[] = FILE_PATH_LITERAL("Cache");
11+const base::FilePath::CharType kCacheDirname2[] = FILE_PATH_LITERAL("Cache2");
12+
13 const base::FilePath::CharType kCookiesFilename[] =
14 FILE_PATH_LITERAL("cookies.sqlite");
15
16@@ -100,22 +104,17 @@
17 const char kDevtoolsDefaultServerIp[] = "127.0.0.1";
18 const int kBackLog = 1;
19
20-void CleanupGPUShaderCache(const base::FilePath& path) {
21- base::FilePath cache = path.Append(FILE_PATH_LITERAL("GPUCache"));
22- if (!base::DirectoryExists(cache)) {
23+void CleanupOldCacheDir(const base::FilePath& path) {
24+ if (!base::DirectoryExists(path)) {
25 return;
26 }
27
28 base::FileEnumerator traversal(
29- cache, false,
30+ path, false,
31 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES);
32 for (base::FilePath current = traversal.Next(); !current.empty();
33 current = traversal.Next()) {
34 if (traversal.GetInfo().IsDirectory()) {
35- LOG(WARNING)
36- << "Not deleting GPU shader cache directory \"" << cache.value()
37- << "\". Directory contains an unexpected sub-directory \""
38- << traversal.GetInfo().GetName().value() << "\"";
39 return;
40 }
41
42@@ -123,14 +122,11 @@
43 if (name != FILE_PATH_LITERAL("index") &&
44 name.compare(0, 5, FILE_PATH_LITERAL("data_")) != 0 &&
45 name.compare(0, 2, FILE_PATH_LITERAL("f_")) != 0) {
46- LOG(WARNING)
47- << "Not deleting GPU shader cache directory \"" << cache.value()
48- << "\". Directory contains an unexpected file \"" << name << "\"";
49 return;
50 }
51 }
52
53- base::DeleteFile(cache, true);
54+ base::DeleteFile(path, true);
55 }
56
57 } // namespace
58@@ -495,14 +491,21 @@
59
60 context->set_transport_security_state(transport_security_state_.get());
61
62+ // Run-once code that is run when upgrading oxide to
63+ // a version that uses the simple cache backend.
64+ content::BrowserThread::PostTask(
65+ content::BrowserThread::FILE,
66+ FROM_HERE,
67+ base::Bind(&CleanupOldCacheDir, GetCachePath().Append(kCacheDirname)));
68+
69 net::HttpCache::BackendFactory* cache_backend = nullptr;
70 if (IsOffTheRecord() || GetCachePath().empty()) {
71 cache_backend = net::HttpCache::DefaultBackend::InMemory(0);
72 } else {
73 cache_backend = new net::HttpCache::DefaultBackend(
74 net::DISK_CACHE,
75- net::CACHE_BACKEND_DEFAULT,
76- GetCachePath().Append(kCacheDirname),
77+ net::CACHE_BACKEND_SIMPLE,
78+ GetCachePath().Append(kCacheDirname2),
79 GetMaxCacheSizeHint() * 1024 * 1024, // MB -> bytes
80 content::BrowserThread::GetMessageLoopProxyForThread(
81 content::BrowserThread::CACHE));
82@@ -717,10 +720,11 @@
83 }
84
85 if (!GetPath().empty()) {
86+ base::FilePath gpu_cache = GetPath().Append(FILE_PATH_LITERAL("GPUCache"));
87 content::BrowserThread::PostTask(
88 content::BrowserThread::FILE,
89 FROM_HERE,
90- base::Bind(&CleanupGPUShaderCache, GetPath()));
91+ base::Bind(&CleanupOldCacheDir, gpu_cache));
92 }
93 }
94

Subscribers

People subscribed via source and target branches