Return backed up TemplateURL on default search change
[chromium-blink-merge.git] / chrome / browser / browsing_data_quota_helper_impl.h
blob83b4629a856e0fde5ea0bbfe8a2f8fe3c4f6a436
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_
6 #define CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_
7 #pragma once
9 #include <map>
10 #include <set>
11 #include <string>
12 #include <utility>
14 #include "base/callback_old.h"
15 #include "base/compiler_specific.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_callback_factory.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "base/time.h"
20 #include "chrome/browser/browsing_data_quota_helper.h"
21 #include "content/public/browser/browser_thread.h"
22 #include "webkit/quota/quota_types.h"
24 namespace quota {
25 class QuotaManager;
28 // Implementation of BrowsingDataQuotaHelper. Since a client of
29 // BrowsingDataQuotaHelper should live in UI thread and QuotaManager lives in
30 // IO thread, we have to communicate over thread using PostTask.
31 class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper {
32 public:
33 virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE;
34 virtual void CancelNotification() OVERRIDE;
35 virtual void RevokeHostQuota(const std::string& host) OVERRIDE;
37 private:
38 BrowsingDataQuotaHelperImpl(base::MessageLoopProxy* ui_thread,
39 base::MessageLoopProxy* io_thread,
40 quota::QuotaManager* quota_manager);
41 virtual ~BrowsingDataQuotaHelperImpl();
43 void FetchQuotaInfo();
45 // Callback function for GetOriginModifiedSince.
46 void GotOrigins(const std::set<GURL>& origins, quota::StorageType type);
48 void ProcessPendingHosts();
49 void GetHostUsage(const std::string& host, quota::StorageType type);
51 // Callback function for GetHostUsage.
52 void GotHostUsage(const std::string& host,
53 quota::StorageType type,
54 int64 usage);
56 void OnComplete();
57 void DidRevokeHostQuota(quota::QuotaStatusCode status,
58 const std::string& host,
59 quota::StorageType type,
60 int64 quota);
62 scoped_refptr<quota::QuotaManager> quota_manager_;
63 FetchResultCallback callback_;
65 typedef std::set<std::pair<std::string, quota::StorageType> > PendingHosts;
66 PendingHosts pending_hosts_;
67 std::map<std::string, QuotaInfo> quota_info_;
69 bool is_fetching_;
71 scoped_refptr<base::MessageLoopProxy> ui_thread_;
72 scoped_refptr<base::MessageLoopProxy> io_thread_;
73 base::WeakPtrFactory<BrowsingDataQuotaHelperImpl> weak_factory_;
75 friend class BrowsingDataQuotaHelper;
76 friend class BrowsingDataQuotaHelperTest;
78 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperImpl);
81 #endif // CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_