summaryrefslogtreecommitdiffstats
path: root/content/public/browser/worker_service.h
blob: 94f20bc0bf818936fedb2d1492c8096370745177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_BROWSER_WORKER_SERVICE_H_
#define CONTENT_PUBLIC_BROWSER_WORKER_SERVICE_H_

#include <vector>

#include "base/process.h"
#include "content/common/content_export.h"

class GURL;

namespace content {

class WorkerServiceObserver;

// A singleton for managing HTML5 shared web workers. These are run in a
// separate process, since multiple renderer processes can be talking to a
// single shared worker. All the methods below can only be called on the IO
// thread.
class WorkerService {
 public:
  virtual ~WorkerService() {}

  // Returns the WorkerService singleton.
  CONTENT_EXPORT static WorkerService* GetInstance();

  // Terminates the given worker. Returns true if the process was found.
  virtual bool TerminateWorker(int process_id, int route_id) = 0;

  struct WorkerInfo {
    GURL url;
    string16 name;
    int process_id;
    int route_id;
    base::ProcessHandle handle;
  };

  // Return information about all the currently running workers.
  virtual std::vector<WorkerInfo> GetWorkers() = 0;

  virtual void AddObserver(WorkerServiceObserver* observer) = 0;
  virtual void RemoveObserver(WorkerServiceObserver* observer) = 0;
};

}  // namespace content

#endif  // CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_