Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / service_worker / service_worker_internals_ui.h
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.
4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_
7
8 #include <set>
9
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"
18
19 namespace base {
20 class ListValue;
21 class DictionaryValue;
22 }
23
24 namespace content {
25
26 class StoragePartition;
27 class ServiceWorkerContextWrapper;
28 class ServiceWorkerRegistration;
29 class ServiceWorkerVersion;
30
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);
38
39   explicit ServiceWorkerInternalsUI(WebUI* web_ui);
40
41  private:
42   class OperationProxy;
43   class PartitionObserver;
44
45   ~ServiceWorkerInternalsUI() override;
46   void AddContextFromStoragePartition(StoragePartition* partition);
47
48   void RemoveObserverFromStoragePartition(StoragePartition* partition);
49
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);
60
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;
67
68   base::ScopedPtrHashMap<uintptr_t, PartitionObserver> observers_;
69   int next_partition_id_;
70 };
71
72 }  // namespace content
73
74 #endif  // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INTERNALS_UI_H_