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

Side by Side Diff: chrome/browser/browsing_data/cache_counter.cc

Issue 2869683002: DEBUG counter logging (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/browsing_data/cache_counter.h" 5 #include "chrome/browser/browsing_data/cache_counter.h"
6 #include "chrome/browser/profiles/profile.h" 6 #include "chrome/browser/profiles/profile.h"
7 #include "components/browsing_data/content/conditional_cache_counting_helper.h" 7 #include "components/browsing_data/content/conditional_cache_counting_helper.h"
8 #include "components/browsing_data/core/pref_names.h" 8 #include "components/browsing_data/core/pref_names.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 11
12 #if defined(OS_ANDROID)
13 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
14 #endif // OS_ANDROID
15
12 CacheCounter::CacheResult::CacheResult(const CacheCounter* source, 16 CacheCounter::CacheResult::CacheResult(const CacheCounter* source,
13 int64_t cache_size, 17 int64_t cache_size,
14 bool is_upper_limit) 18 bool is_upper_limit)
15 : FinishedResult(source, cache_size), 19 : FinishedResult(source, cache_size),
16 cache_size_(cache_size), 20 cache_size_(cache_size),
17 is_upper_limit_(is_upper_limit) {} 21 is_upper_limit_(is_upper_limit) {}
18 22
19 CacheCounter::CacheResult::~CacheResult() {} 23 CacheCounter::CacheResult::~CacheResult() {}
20 24
21 CacheCounter::CacheCounter(Profile* profile) 25 CacheCounter::CacheCounter(Profile* profile)
22 : profile_(profile), 26 : profile_(profile),
23 weak_ptr_factory_(this) {} 27 weak_ptr_factory_(this) {}
24 28
25 CacheCounter::~CacheCounter() { 29 CacheCounter::~CacheCounter() {
26 } 30 }
27 31
28 const char* CacheCounter::GetPrefName() const { 32 const char* CacheCounter::GetPrefName() const {
29 return GetTab() == browsing_data::ClearBrowsingDataTab::BASIC 33 return GetTab() == browsing_data::ClearBrowsingDataTab::BASIC
30 ? browsing_data::prefs::kDeleteCacheBasic 34 ? browsing_data::prefs::kDeleteCacheBasic
31 : browsing_data::prefs::kDeleteCache; 35 : browsing_data::prefs::kDeleteCache;
32 } 36 }
33 37
34 void CacheCounter::Count() { 38 void CacheCounter::Count() {
39 LOG(ERROR) << "START COUNTING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
40
35 base::WeakPtr<browsing_data::ConditionalCacheCountingHelper> counter = 41 base::WeakPtr<browsing_data::ConditionalCacheCountingHelper> counter =
36 browsing_data::ConditionalCacheCountingHelper::CreateForRange( 42 browsing_data::ConditionalCacheCountingHelper::CreateForRange(
37 content::BrowserContext::GetDefaultStoragePartition(profile_), 43 content::BrowserContext::GetDefaultStoragePartition(profile_),
38 GetPeriodStart(), base::Time::Max()) 44 GetPeriodStart(), base::Time::Max())
39 ->CountAndDestroySelfWhenFinished( 45 ->CountAndDestroySelfWhenFinished(
40 base::Bind(&CacheCounter::OnCacheSizeCalculated, 46 base::Bind(&CacheCounter::OnCacheSizeCalculated,
41 weak_ptr_factory_.GetWeakPtr())); 47 weak_ptr_factory_.GetWeakPtr()));
42 } 48 }
43 49
44 void CacheCounter::OnCacheSizeCalculated(int64_t result_bytes, 50 void CacheCounter::OnCacheSizeCalculated(int64_t cache_bytes,
45 bool is_upper_limit) { 51 bool is_upper_limit) {
46 // A value less than 0 means a net error code. 52 // A value less than 0 means a net error code.
47 if (result_bytes < 0) 53 if (cache_bytes < 0)
48 return; 54 return;
55
56 #if defined(OS_ANDROID)
57 if (offline_pages::OfflinePageUtils::GetCachedOfflinePageSizeBetween(
58 profile_,
59 base::Bind(&CacheCounter::OnOfflinePageSizeCalculated,
60 weak_ptr_factory_.GetWeakPtr(), cache_bytes,
61 is_upper_limit),
62 GetPeriodStart(), base::Time::Max())) {
63 LOG(ERROR) << "START COUNTING OFFLINE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
64
65 return;
66 }
67 #endif // OS_ANDROID
49 auto result = 68 auto result =
50 base::MakeUnique<CacheResult>(this, result_bytes, is_upper_limit); 69 base::MakeUnique<CacheResult>(this, cache_bytes, is_upper_limit);
70 LOG(ERROR) << "REPORT RESULT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
51 ReportResult(std::move(result)); 71 ReportResult(std::move(result));
52 } 72 }
73
74 #if defined(OS_ANDROID)
75 void CacheCounter::OnOfflinePageSizeCalculated(
76 int64_t cache_bytes,
77 bool is_upper_limit,
78 int64_t cached_offline_page_bytes) {
79 auto result = base::MakeUnique<CacheResult>(
80 this, cached_offline_page_bytes + cache_bytes, is_upper_limit);
81 LOG(ERROR) << "REPORT RESULT OFFLINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
82 ReportResult(std::move(result));
83 }
84 #endif // OS_ANDROID
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/cache_counter.h ('k') | components/offline_pages/core/client_policy_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698