Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / service_worker / embedded_worker_dispatcher.h
blob0ecd75a873e8076c554ece7e790cb51c4c9bb351
1 // Copyright 2013 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_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_
6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_
8 #include <map>
10 #include "base/basictypes.h"
11 #include "base/id_map.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "ipc/ipc_listener.h"
16 struct EmbeddedWorkerMsg_StartWorker_Params;
17 class GURL;
19 namespace content {
21 // A tiny dispatcher which handles embedded worker start/stop messages.
22 class EmbeddedWorkerDispatcher : public IPC::Listener {
23 public:
24 EmbeddedWorkerDispatcher();
25 ~EmbeddedWorkerDispatcher() override;
27 // IPC::Listener overrides.
28 bool OnMessageReceived(const IPC::Message& message) override;
30 void WorkerContextDestroyed(int embedded_worker_id);
32 private:
33 class WorkerWrapper;
35 void OnStartWorker(const EmbeddedWorkerMsg_StartWorker_Params& params);
36 void OnStopWorker(int embedded_worker_id);
38 IDMap<WorkerWrapper, IDMapOwnPointer> workers_;
39 std::map<int /* embedded_worker_id */, base::TimeTicks> stop_worker_times_;
40 base::WeakPtrFactory<EmbeddedWorkerDispatcher> weak_factory_;
42 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDispatcher);
45 } // namespace content
47 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_