[Storage] Blob Storage Refactoring pt 1:
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_internals_ui.h
blobf0c09d6861611f19f1eb3bf566096d4c7ff2b5ad
1 // Copyright 2014 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 CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_
8 #include <set>
10 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "content/browser/service_worker/service_worker_context_observer.h"
16 #include "content/common/service_worker/service_worker_status_code.h"
17 #include "content/public/browser/web_ui_controller.h"
19 namespace base {
20 class ListValue;
21 class DictionaryValue;
24 namespace content {
26 class StoragePartition;
27 class ServiceWorkerContextWrapper;
28 class ServiceWorkerRegistration;
29 class ServiceWorkerVersion;
31 class ServiceWorkerInternalsUI
32 : public WebUIController,
33 public base::SupportsWeakPtr<ServiceWorkerInternalsUI> {
34 public:
35 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback;
36 typedef void (ServiceWorkerVersion::*ServiceWorkerVersionMethod)(
37 const StatusCallback& callback);
39 explicit ServiceWorkerInternalsUI(WebUI* web_ui);
41 private:
42 class OperationProxy;
43 class PartitionObserver;
45 ~ServiceWorkerInternalsUI() override;
46 void AddContextFromStoragePartition(StoragePartition* partition);
48 void RemoveObserverFromStoragePartition(StoragePartition* partition);
50 // Called from Javascript.
51 void GetOptions(const base::ListValue* args);
52 void SetOption(const base::ListValue* args);
53 void GetAllRegistrations(const base::ListValue* args);
54 void CallServiceWorkerVersionMethod(ServiceWorkerVersionMethod method,
55 const base::ListValue* args);
56 void DispatchPushEvent(const base::ListValue* args);
57 void InspectWorker(const base::ListValue* args);
58 void Unregister(const base::ListValue* args);
59 void StartWorker(const base::ListValue* args);
61 bool GetServiceWorkerContext(
62 int partition_id,
63 scoped_refptr<ServiceWorkerContextWrapper>* context) const;
64 void FindContext(int partition_id,
65 StoragePartition** result_partition,
66 StoragePartition* storage_partition) const;
68 base::ScopedPtrHashMap<uintptr_t, PartitionObserver> observers_;
69 int next_partition_id_;
72 } // namespace content
74 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_