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 "base/basictypes.h"
9 #include "base/id_map.h"
10 #include "base/memory/weak_ptr.h"
11 #include "ipc/ipc_listener.h"
13 struct EmbeddedWorkerMsg_StartWorker_Params
;
18 // A tiny dispatcher which handles embedded worker start/stop messages.
19 class EmbeddedWorkerDispatcher
: public IPC::Listener
{
21 EmbeddedWorkerDispatcher();
22 ~EmbeddedWorkerDispatcher() override
;
24 // IPC::Listener overrides.
25 bool OnMessageReceived(const IPC::Message
& message
) override
;
27 void WorkerContextDestroyed(int embedded_worker_id
);
32 void OnStartWorker(const EmbeddedWorkerMsg_StartWorker_Params
& params
);
33 void OnStopWorker(int embedded_worker_id
);
35 IDMap
<WorkerWrapper
, IDMapOwnPointer
> workers_
;
36 base::WeakPtrFactory
<EmbeddedWorkerDispatcher
> weak_factory_
;
38 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDispatcher
);
41 } // namespace content
43 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_DISPATCHER_H_