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

Side by Side Diff: content/browser/cache_storage/cache_storage.cc

Issue 1428463002: [CacheStorage] Fix a failed cache migration issue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/cache_storage/cache_storage.h" 5 #include "content/browser/cache_storage/cache_storage.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/barrier_closure.h" 10 #include "base/barrier_closure.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 cache_path = origin_path.AppendASCII(cache_dir); 394 cache_path = origin_path.AppendASCII(cache_dir);
395 } while (base::PathExists(cache_path)); 395 } while (base::PathExists(cache_path));
396 396
397 if (!base::Move(legacy_cache_path, cache_path)) { 397 if (!base::Move(legacy_cache_path, cache_path)) {
398 // If the move fails then the cache is in a bad state. Return an empty 398 // If the move fails then the cache is in a bad state. Return an empty
399 // index so that the CacheStorage can start fresh. The unreferenced 399 // index so that the CacheStorage can start fresh. The unreferenced
400 // caches will be discarded later in initialization. 400 // caches will be discarded later in initialization.
401 return kBadIndexState; 401 return kBadIndexState;
402 } 402 }
403 403
404 index.mutable_cache(0)->set_cache_dir(cache_dir); 404 index.mutable_cache(i)->set_cache_dir(cache_dir);
405 index_is_dirty = true; 405 index_is_dirty = true;
406 } 406 }
407 } 407 }
408 408
409 if (index_is_dirty) { 409 if (index_is_dirty) {
410 std::string new_body; 410 std::string new_body;
411 if (!index.SerializeToString(&new_body)) 411 if (!index.SerializeToString(&new_body))
412 return kBadIndexState; 412 return kBadIndexState;
413 if (base::WriteFile(index_path, new_body.c_str(), new_body.size()) != 413 if (base::WriteFile(index_path, new_body.c_str(), new_body.size()) !=
414 base::checked_cast<int>(new_body.size())) 414 base::checked_cast<int>(new_body.size()))
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 scoped_ptr<ServiceWorkerResponse> response, 934 scoped_ptr<ServiceWorkerResponse> response,
935 scoped_ptr<storage::BlobDataHandle> blob_data_handle) { 935 scoped_ptr<storage::BlobDataHandle> blob_data_handle) {
936 base::WeakPtr<CacheStorage> cache_storage = weak_factory_.GetWeakPtr(); 936 base::WeakPtr<CacheStorage> cache_storage = weak_factory_.GetWeakPtr();
937 937
938 callback.Run(error, response.Pass(), blob_data_handle.Pass()); 938 callback.Run(error, response.Pass(), blob_data_handle.Pass());
939 if (cache_storage) 939 if (cache_storage)
940 scheduler_->CompleteOperationAndRunNext(); 940 scheduler_->CompleteOperationAndRunNext();
941 } 941 }
942 942
943 } // namespace content 943 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698