| OLD | NEW |
| 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 "webkit/dom_storage/dom_storage_area.h" | 5 #include "webkit/dom_storage/dom_storage_area.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 static const int kCommitTimerSeconds = 1; | 27 static const int kCommitTimerSeconds = 1; |
| 28 | 28 |
| 29 DomStorageArea::CommitBatch::CommitBatch() | 29 DomStorageArea::CommitBatch::CommitBatch() |
| 30 : clear_all_first(false) { | 30 : clear_all_first(false) { |
| 31 } | 31 } |
| 32 DomStorageArea::CommitBatch::~CommitBatch() {} | 32 DomStorageArea::CommitBatch::~CommitBatch() {} |
| 33 | 33 |
| 34 | 34 |
| 35 // static | 35 // static |
| 36 const FilePath::CharType DomStorageArea::kDatabaseFileExtension[] = | 36 const base::FilePath::CharType DomStorageArea::kDatabaseFileExtension[] = |
| 37 FILE_PATH_LITERAL(".localstorage"); | 37 FILE_PATH_LITERAL(".localstorage"); |
| 38 | 38 |
| 39 // static | 39 // static |
| 40 FilePath DomStorageArea::DatabaseFileNameFromOrigin(const GURL& origin) { | 40 base::FilePath DomStorageArea::DatabaseFileNameFromOrigin(const GURL& origin) { |
| 41 std::string filename = fileapi::GetOriginIdentifierFromURL(origin); | 41 std::string filename = fileapi::GetOriginIdentifierFromURL(origin); |
| 42 // There is no FilePath.AppendExtension() method, so start with just the | 42 // There is no base::FilePath.AppendExtension() method, so start with just the |
| 43 // extension as the filename, and then InsertBeforeExtension the desired | 43 // extension as the filename, and then InsertBeforeExtension the desired |
| 44 // name. | 44 // name. |
| 45 return FilePath().Append(kDatabaseFileExtension). | 45 return base::FilePath().Append(kDatabaseFileExtension). |
| 46 InsertBeforeExtensionASCII(filename); | 46 InsertBeforeExtensionASCII(filename); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 GURL DomStorageArea::OriginFromDatabaseFileName(const FilePath& name) { | 50 GURL DomStorageArea::OriginFromDatabaseFileName(const base::FilePath& name) { |
| 51 DCHECK(name.MatchesExtension(kDatabaseFileExtension)); | 51 DCHECK(name.MatchesExtension(kDatabaseFileExtension)); |
| 52 WebKit::WebString origin_id = webkit_base::FilePathToWebString( | 52 WebKit::WebString origin_id = webkit_base::FilePathToWebString( |
| 53 name.BaseName().RemoveExtension()); | 53 name.BaseName().RemoveExtension()); |
| 54 return DatabaseUtil::GetOriginFromIdentifier(origin_id); | 54 return DatabaseUtil::GetOriginFromIdentifier(origin_id); |
| 55 } | 55 } |
| 56 | 56 |
| 57 DomStorageArea::DomStorageArea(const GURL& origin, const FilePath& directory, | 57 DomStorageArea::DomStorageArea(const GURL& origin, const base::FilePath& directo
ry, |
| 58 DomStorageTaskRunner* task_runner) | 58 DomStorageTaskRunner* task_runner) |
| 59 : namespace_id_(kLocalStorageNamespaceId), origin_(origin), | 59 : namespace_id_(kLocalStorageNamespaceId), origin_(origin), |
| 60 directory_(directory), | 60 directory_(directory), |
| 61 task_runner_(task_runner), | 61 task_runner_(task_runner), |
| 62 map_(new DomStorageMap(kPerAreaQuota + kPerAreaOverQuotaAllowance)), | 62 map_(new DomStorageMap(kPerAreaQuota + kPerAreaOverQuotaAllowance)), |
| 63 is_initial_import_done_(true), | 63 is_initial_import_done_(true), |
| 64 is_shutdown_(false), | 64 is_shutdown_(false), |
| 65 commit_batches_in_flight_(0) { | 65 commit_batches_in_flight_(0) { |
| 66 if (!directory.empty()) { | 66 if (!directory.empty()) { |
| 67 FilePath path = directory.Append(DatabaseFileNameFromOrigin(origin_)); | 67 base::FilePath path = directory.Append(DatabaseFileNameFromOrigin(origin_)); |
| 68 backing_.reset(new LocalStorageDatabaseAdapter(path)); | 68 backing_.reset(new LocalStorageDatabaseAdapter(path)); |
| 69 is_initial_import_done_ = false; | 69 is_initial_import_done_ = false; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 DomStorageArea::DomStorageArea( | 73 DomStorageArea::DomStorageArea( |
| 74 int64 namespace_id, | 74 int64 namespace_id, |
| 75 const std::string& persistent_namespace_id, | 75 const std::string& persistent_namespace_id, |
| 76 const GURL& origin, | 76 const GURL& origin, |
| 77 SessionStorageDatabase* session_storage_backing, | 77 SessionStorageDatabase* session_storage_backing, |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 commit_batch_->clear_all_first, | 360 commit_batch_->clear_all_first, |
| 361 commit_batch_->changed_values); | 361 commit_batch_->changed_values); |
| 362 DCHECK(success); | 362 DCHECK(success); |
| 363 } | 363 } |
| 364 commit_batch_.reset(); | 364 commit_batch_.reset(); |
| 365 backing_.reset(); | 365 backing_.reset(); |
| 366 session_storage_backing_ = NULL; | 366 session_storage_backing_ = NULL; |
| 367 } | 367 } |
| 368 | 368 |
| 369 } // namespace dom_storage | 369 } // namespace dom_storage |
| OLD | NEW |