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_
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
;
21 // A tiny dispatcher which handles embedded worker start/stop messages.
22 class EmbeddedWorkerDispatcher
: public IPC::Listener
{
24 EmbeddedWorkerDispatcher();
25 ~EmbeddedWorkerDispatcher() override
;
27 // IPC::Listener overrides.
28 bool OnMessageReceived(const IPC::Message
& message
) override
;
30 void WorkerContextDestroyed(int embedded_worker_id
);
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_