blob: 31dac38451df56cc61e40ca7aa52bb152769091c [file] [log] [blame]
[email protected]f8988502011-07-13 13:21:091// 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.
4
5#ifndef CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_
6#define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_
[email protected]f8988502011-07-13 13:21:097
8#include <map>
9#include <string>
10#include <vector>
11
12#include "base/memory/ref_counted.h"
[email protected]26e2632a2011-12-31 04:02:5513#include "content/public/browser/web_ui_message_handler.h"
[email protected]f8988502011-07-13 13:21:0914#include "webkit/quota/quota_types.h"
15
16namespace base {
17class Value;
18class ListValue;
19}
20
21namespace quota_internals {
22
23class QuotaInternalsProxy;
24class GlobalStorageInfo;
25class PerHostStorageInfo;
26class PerOriginStorageInfo;
27typedef std::map<std::string, std::string> Statistics;
28
29// This class handles message from WebUI page of chrome://quota-internals/.
30// All methods in this class should be called on UI thread.
[email protected]26e2632a2011-12-31 04:02:5531class QuotaInternalsHandler : public content::WebUIMessageHandler {
[email protected]f8988502011-07-13 13:21:0932 public:
33 QuotaInternalsHandler();
34 virtual ~QuotaInternalsHandler();
35 virtual void RegisterMessages() OVERRIDE;
36
37 // Called by QuotaInternalsProxy to report information to WebUI page.
38 void ReportAvailableSpace(int64 available_space);
39 void ReportGlobalInfo(const GlobalStorageInfo& data);
40 void ReportPerHostInfo(const std::vector<PerHostStorageInfo>& hosts);
41 void ReportPerOriginInfo(const std::vector<PerOriginStorageInfo>& origins);
42 void ReportStatistics(const Statistics& stats);
43
44 private:
45 void OnRequestInfo(const base::ListValue*);
46 void SendMessage(const std::string& message, const base::Value& value);
47
48 scoped_refptr<QuotaInternalsProxy> proxy_;
49
50 DISALLOW_COPY_AND_ASSIGN(QuotaInternalsHandler);
51};
52} // quota_internals
53
54#endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_HANDLER_H_