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

Side by Side Diff: webkit/fileapi/quota_file_util.cc

Issue 7671039: Count-up/down the dirty count in the usage cache at FileSystemOperation, not at QuotaFU. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/fileapi/quota_file_util.h" 5 #include "webkit/fileapi/quota_file_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "webkit/fileapi/file_system_context.h" 9 #include "webkit/fileapi/file_system_context.h"
10 #include "webkit/fileapi/file_system_operation_context.h" 10 #include "webkit/fileapi/file_system_operation_context.h"
11 #include "webkit/fileapi/file_system_path_manager.h" 11 #include "webkit/fileapi/file_system_path_manager.h"
12 #include "webkit/fileapi/file_system_quota_util.h" 12 #include "webkit/fileapi/file_system_quota_util.h"
13 #include "webkit/quota/quota_manager.h" 13 #include "webkit/quota/quota_manager.h"
14 14
15 using quota::QuotaManagerProxy; 15 using quota::QuotaManagerProxy;
16 16
17 namespace fileapi { 17 namespace fileapi {
18 18
19 const int64 QuotaFileUtil::kNoLimit = kint64max; 19 const int64 QuotaFileUtil::kNoLimit = kint64max;
20 20
21 // See the comment in the header file as for these constants. 21 // See the comment in the header file as for these constants.
22 const int64 QuotaFileUtil::kFilePathCostPerChar = 2; 22 const int64 QuotaFileUtil::kFilePathCostPerChar = 2;
23 const int64 QuotaFileUtil::kFilePathCostPerFile = 146; 23 const int64 QuotaFileUtil::kFilePathCostPerFile = 146;
24 24
25 namespace { 25 namespace {
26 26
27 // A helper class to hook quota_util() methods before and after modifications. 27 // A helper class to hook quota_util() methods before and after modifications.
28 class ScopedOriginUpdateHelper { 28 class ScopedOriginUpdateHelper {
ericu 2011/08/19 04:12:59 Does this class now not actually do anything "scop
Dai Mikurube (NOT FULLTIME) 2011/08/19 10:21:10 Agreed. I'll fix it in the next patch.
29 public: 29 public:
30 explicit ScopedOriginUpdateHelper( 30 explicit ScopedOriginUpdateHelper(
31 FileSystemOperationContext* operation_context, 31 FileSystemOperationContext* operation_context,
32 const GURL& origin_url, 32 const GURL& origin_url,
33 FileSystemType type) 33 FileSystemType type)
34 : operation_context_(operation_context), 34 : operation_context_(operation_context),
35 origin_url_(origin_url), 35 origin_url_(origin_url),
36 type_(type) { 36 type_(type) {
37 DCHECK(operation_context_); 37 DCHECK(operation_context_);
38 DCHECK(operation_context_->file_system_context()); 38 DCHECK(operation_context_->file_system_context());
39 DCHECK(type != kFileSystemTypeUnknown); 39 DCHECK(type != kFileSystemTypeUnknown);
40 quota_util_ = 40 quota_util_ =
41 operation_context_->file_system_context()->GetQuotaUtil(type_); 41 operation_context_->file_system_context()->GetQuotaUtil(type_);
42 quota_manager_proxy_ = 42 quota_manager_proxy_ =
43 operation_context_->file_system_context()->quota_manager_proxy(); 43 operation_context_->file_system_context()->quota_manager_proxy();
44 if (quota_util_)
45 quota_util_->StartUpdateOriginOnFileThread(origin_url_, type_);
46 } 44 }
47 45
48 ~ScopedOriginUpdateHelper() { 46 ~ScopedOriginUpdateHelper() {
49 if (quota_util_)
50 quota_util_->EndUpdateOriginOnFileThread(origin_url_, type_);
51 } 47 }
52 48
53 void NotifyUpdate(int64 growth) { 49 void NotifyUpdate(int64 growth) {
54 if (operation_context_->allowed_bytes_growth() != QuotaFileUtil::kNoLimit) 50 if (operation_context_->allowed_bytes_growth() != QuotaFileUtil::kNoLimit)
55 operation_context_->set_allowed_bytes_growth( 51 operation_context_->set_allowed_bytes_growth(
56 operation_context_->allowed_bytes_growth() - growth); 52 operation_context_->allowed_bytes_growth() - growth);
57 if (quota_util_) 53 if (quota_util_)
58 quota_util_->UpdateOriginUsageOnFileThread( 54 quota_util_->UpdateOriginUsageOnFileThread(
59 quota_manager_proxy_, origin_url_, type_, growth); 55 quota_manager_proxy_, origin_url_, type_, growth);
60 } 56 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 343 }
348 *growth = src_file_info.size - dest_file_info.size + dest_file_path_cost; 344 *growth = src_file_info.size - dest_file_info.size + dest_file_path_cost;
349 if (allowed_bytes_growth != QuotaFileUtil::kNoLimit && 345 if (allowed_bytes_growth != QuotaFileUtil::kNoLimit &&
350 *growth > allowed_bytes_growth) 346 *growth > allowed_bytes_growth)
351 return false; 347 return false;
352 348
353 return true; 349 return true;
354 } 350 }
355 351
356 } // namespace fileapi 352 } // namespace fileapi
OLDNEW
« webkit/fileapi/file_system_operation.cc ('K') | « webkit/fileapi/file_system_operation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698