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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_store_file.cc

Issue 381243002: [safe browsing] Delete temporary files on cancelled update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« 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 (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/safe_browsing/safe_browsing_store_file.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_file.h" 8 #include "base/files/scoped_file.h"
9 #include "base/md5.h" 9 #include "base/md5.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 return false; 1175 return false;
1176 } 1176 }
1177 1177
1178 DCHECK(!new_file_.get()); 1178 DCHECK(!new_file_.get());
1179 DCHECK(!file_.get()); 1179 DCHECK(!file_.get());
1180 1180
1181 return Close(); 1181 return Close();
1182 } 1182 }
1183 1183
1184 bool SafeBrowsingStoreFile::CancelUpdate() { 1184 bool SafeBrowsingStoreFile::CancelUpdate() {
1185 return Close(); 1185 bool ret = Close();
1186
1187 // Delete stale staging file.
1188 const base::FilePath new_filename = TemporaryFileForFilename(filename_);
1189 base::DeleteFile(new_filename, false);
1190
1191 return ret;
1186 } 1192 }
1187 1193
1188 void SafeBrowsingStoreFile::SetAddChunk(int32 chunk_id) { 1194 void SafeBrowsingStoreFile::SetAddChunk(int32 chunk_id) {
1189 add_chunks_cache_.insert(chunk_id); 1195 add_chunks_cache_.insert(chunk_id);
1190 } 1196 }
1191 1197
1192 bool SafeBrowsingStoreFile::CheckAddChunk(int32 chunk_id) { 1198 bool SafeBrowsingStoreFile::CheckAddChunk(int32 chunk_id) {
1193 return add_chunks_cache_.count(chunk_id) > 0; 1199 return add_chunks_cache_.count(chunk_id) > 0;
1194 } 1200 }
1195 1201
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 // With SQLite support gone, one way to get to this code is if the 1243 // With SQLite support gone, one way to get to this code is if the
1238 // existing file is a SQLite file. Make sure the journal file is 1244 // existing file is a SQLite file. Make sure the journal file is
1239 // also removed. 1245 // also removed.
1240 const base::FilePath journal_filename( 1246 const base::FilePath journal_filename(
1241 basename.value() + FILE_PATH_LITERAL("-journal")); 1247 basename.value() + FILE_PATH_LITERAL("-journal"));
1242 if (base::PathExists(journal_filename)) 1248 if (base::PathExists(journal_filename))
1243 base::DeleteFile(journal_filename, false); 1249 base::DeleteFile(journal_filename, false);
1244 1250
1245 return true; 1251 return true;
1246 } 1252 }
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