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_
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"
21 class DictionaryValue
;
26 class StoragePartition
;
27 class ServiceWorkerContextWrapper
;
28 class ServiceWorkerVersion
;
30 class ServiceWorkerInternalsUI
31 : public WebUIController
,
32 public base::SupportsWeakPtr
<ServiceWorkerInternalsUI
> {
34 typedef base::Callback
<void(ServiceWorkerStatusCode
)> StatusCallback
;
35 typedef void (ServiceWorkerVersion::*ServiceWorkerVersionMethod
)(
36 const StatusCallback
& callback
);
38 explicit ServiceWorkerInternalsUI(WebUI
* web_ui
);
42 class PartitionObserver
;
44 ~ServiceWorkerInternalsUI() override
;
45 void AddContextFromStoragePartition(StoragePartition
* partition
);
47 void RemoveObserverFromStoragePartition(StoragePartition
* partition
);
49 // Called from Javascript.
50 void GetOptions(const base::ListValue
* args
);
51 void SetOption(const base::ListValue
* args
);
52 void GetAllRegistrations(const base::ListValue
* args
);
53 void CallServiceWorkerVersionMethod(ServiceWorkerVersionMethod method
,
54 const base::ListValue
* args
);
55 void DispatchPushEvent(const base::ListValue
* args
);
56 void InspectWorker(const base::ListValue
* args
);
57 void Unregister(const base::ListValue
* args
);
58 void StartWorker(const base::ListValue
* args
);
60 bool GetServiceWorkerContext(
62 scoped_refptr
<ServiceWorkerContextWrapper
>* context
) const;
63 void FindContext(int partition_id
,
64 StoragePartition
** result_partition
,
65 StoragePartition
* storage_partition
) const;
67 base::ScopedPtrHashMap
<uintptr_t, PartitionObserver
> observers_
;
68 int next_partition_id_
;
71 } // namespace content
73 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_