| OLD | NEW | 
|---|
| 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 "components/enhanced_bookmarks/persistent_image_store.h" | 5 #include "components/enhanced_bookmarks/persistent_image_store.h" | 
| 6 | 6 | 
|  | 7 #include <stddef.h> | 
|  | 8 | 
| 7 #include "base/files/file.h" | 9 #include "base/files/file.h" | 
| 8 #include "base/logging.h" | 10 #include "base/logging.h" | 
| 9 #include "components/enhanced_bookmarks/image_store_util.h" | 11 #include "components/enhanced_bookmarks/image_store_util.h" | 
| 10 #include "sql/statement.h" | 12 #include "sql/statement.h" | 
| 11 #include "sql/transaction.h" | 13 #include "sql/transaction.h" | 
| 12 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" | 
| 13 #include "url/gurl.h" | 15 #include "url/gurl.h" | 
| 14 | 16 | 
| 15 namespace { | 17 namespace { | 
| 16 // Current version number. Databases are written at the "current" version | 18 // Current version number. Databases are written at the "current" version | 
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 300 void PersistentImageStore::ClearAll() { | 302 void PersistentImageStore::ClearAll() { | 
| 301   DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 303   DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 
| 302   if (OpenDatabase() != sql::INIT_OK) | 304   if (OpenDatabase() != sql::INIT_OK) | 
| 303     return; | 305     return; | 
| 304 | 306 | 
| 305   sql::Statement statement(db_.GetCachedStatement( | 307   sql::Statement statement(db_.GetCachedStatement( | 
| 306       SQL_FROM_HERE, "DELETE FROM images_by_url")); | 308       SQL_FROM_HERE, "DELETE FROM images_by_url")); | 
| 307   statement.Run(); | 309   statement.Run(); | 
| 308 } | 310 } | 
| 309 | 311 | 
| 310 int64 PersistentImageStore::GetStoreSizeInBytes() { | 312 int64_t PersistentImageStore::GetStoreSizeInBytes() { | 
| 311   base::File file(path_, base::File::FLAG_OPEN | base::File::FLAG_READ); | 313   base::File file(path_, base::File::FLAG_OPEN | base::File::FLAG_READ); | 
| 312   return file.IsValid() ? file.GetLength() : -1; | 314   return file.IsValid() ? file.GetLength() : -1; | 
| 313 } | 315 } | 
| 314 | 316 | 
| 315 PersistentImageStore::~PersistentImageStore() { | 317 PersistentImageStore::~PersistentImageStore() { | 
| 316   DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 318   DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 
| 317 } | 319 } | 
| 318 | 320 | 
| 319 sql::InitStatus PersistentImageStore::OpenDatabase() { | 321 sql::InitStatus PersistentImageStore::OpenDatabase() { | 
| 320   DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 322   DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 332 | 334 | 
| 333     // Can't open, raze(). | 335     // Can't open, raze(). | 
| 334     if (db_.is_open()) | 336     if (db_.is_open()) | 
| 335       db_.Raze(); | 337       db_.Raze(); | 
| 336     db_.Close(); | 338     db_.Close(); | 
| 337   } | 339   } | 
| 338 | 340 | 
| 339   DCHECK(false) << "Can't open image DB"; | 341   DCHECK(false) << "Can't open image DB"; | 
| 340   return sql::INIT_FAILURE; | 342   return sql::INIT_FAILURE; | 
| 341 } | 343 } | 
| OLD | NEW | 
|---|