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

Side by Side Diff: chrome/browser/chromeos/drive/stale_cache_files_remover.cc

Issue 15060002: drive: Rename FileCache methods in a blocking pool centric manner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove virtual 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/drive/stale_cache_files_remover.h" 5 #include "chrome/browser/chromeos/drive/stale_cache_files_remover.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/chromeos/drive/drive.pb.h" 8 #include "chrome/browser/chromeos/drive/drive.pb.h"
9 #include "chrome/browser/chromeos/drive/file_cache.h" 9 #include "chrome/browser/chromeos/drive/file_cache.h"
10 #include "chrome/browser/chromeos/drive/file_system.h" 10 #include "chrome/browser/chromeos/drive/file_system.h"
(...skipping 25 matching lines...) Expand all
36 file_system_->AddObserver(this); 36 file_system_->AddObserver(this);
37 } 37 }
38 38
39 StaleCacheFilesRemover::~StaleCacheFilesRemover() { 39 StaleCacheFilesRemover::~StaleCacheFilesRemover() {
40 file_system_->RemoveObserver(this); 40 file_system_->RemoveObserver(this);
41 } 41 }
42 42
43 void StaleCacheFilesRemover::OnInitialLoadFinished() { 43 void StaleCacheFilesRemover::OnInitialLoadFinished() {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
45 45
46 cache_->Iterate( 46 cache_->IterateOnUIThread(
47 base::Bind( 47 base::Bind(
48 &StaleCacheFilesRemover::GetEntryInfoAndRemoveCacheIfNecessary, 48 &StaleCacheFilesRemover::GetEntryInfoAndRemoveCacheIfNecessary,
49 weak_ptr_factory_.GetWeakPtr()), 49 weak_ptr_factory_.GetWeakPtr()),
50 base::Bind(&base::DoNothing)); 50 base::Bind(&base::DoNothing));
51 } 51 }
52 52
53 void StaleCacheFilesRemover::GetEntryInfoAndRemoveCacheIfNecessary( 53 void StaleCacheFilesRemover::GetEntryInfoAndRemoveCacheIfNecessary(
54 const std::string& resource_id, 54 const std::string& resource_id,
55 const FileCacheEntry& cache_entry) { 55 const FileCacheEntry& cache_entry) {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
57 57
58 file_system_->GetEntryInfoByResourceId( 58 file_system_->GetEntryInfoByResourceId(
59 resource_id, 59 resource_id,
60 base::Bind(&StaleCacheFilesRemover::RemoveCacheIfNecessary, 60 base::Bind(&StaleCacheFilesRemover::RemoveCacheIfNecessary,
61 weak_ptr_factory_.GetWeakPtr(), 61 weak_ptr_factory_.GetWeakPtr(),
62 resource_id, 62 resource_id,
63 cache_entry.md5())); 63 cache_entry.md5()));
64 } 64 }
65 65
66 void StaleCacheFilesRemover::RemoveCacheIfNecessary( 66 void StaleCacheFilesRemover::RemoveCacheIfNecessary(
67 const std::string& resource_id, 67 const std::string& resource_id,
68 const std::string& cache_md5, 68 const std::string& cache_md5,
69 FileError error, 69 FileError error,
70 const base::FilePath& drive_file_path, 70 const base::FilePath& drive_file_path,
71 scoped_ptr<ResourceEntry> entry) { 71 scoped_ptr<ResourceEntry> entry) {
72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
73 73
74 // The entry is not found in the file system. 74 // The entry is not found in the file system.
75 if (error != FILE_ERROR_OK) { 75 if (error != FILE_ERROR_OK) {
76 cache_->Remove(resource_id, base::Bind(&EmitErrorLog, resource_id)); 76 cache_->RemoveOnUIThread(resource_id,
77 base::Bind(&EmitErrorLog, resource_id));
77 return; 78 return;
78 } 79 }
79 80
80 // The entry is found but the MD5 does not match. 81 // The entry is found but the MD5 does not match.
81 DCHECK(entry.get()); 82 DCHECK(entry.get());
82 if (!entry->has_file_specific_info() || 83 if (!entry->has_file_specific_info() ||
83 cache_md5 != entry->file_specific_info().file_md5()) { 84 cache_md5 != entry->file_specific_info().file_md5()) {
84 cache_->Remove(resource_id, base::Bind(&EmitErrorLog, resource_id)); 85 cache_->RemoveOnUIThread(resource_id,
86 base::Bind(&EmitErrorLog, resource_id));
85 return; 87 return;
86 } 88 }
87 } 89 }
88 90
89 } // namespace drive 91 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698