worker_service.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright (c) 2012 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_PUBLIC_BROWSER_WORKER_SERVICE_H_ 6#define CONTENT_PUBLIC_BROWSER_WORKER_SERVICE_H_ 7 8#include <vector> 9 10#include "base/process/process.h" 11#include "content/common/content_export.h" 12#include "url/gurl.h" 13 14namespace content { 15 16class WorkerServiceObserver; 17 18// A singleton for managing HTML5 shared web workers. These are run in a 19// separate process, since multiple renderer processes can be talking to a 20// single shared worker. All the methods below can only be called on the IO 21// thread. 22class WorkerService { 23 public: 24 virtual ~WorkerService() {} 25 26 // Returns the WorkerService singleton. 27 CONTENT_EXPORT static WorkerService* GetInstance(); 28 29 // Determines whether embedded SharedWorker is enabled. 30 CONTENT_EXPORT static bool EmbeddedSharedWorkerEnabled(); 31 32 // Terminates the given worker. Returns true if the process was found. 33 virtual bool TerminateWorker(int process_id, int route_id) = 0; 34 35 struct WorkerInfo { 36 GURL url; 37 base::string16 name; 38 int process_id; 39 int route_id; 40 base::ProcessHandle handle; 41 }; 42 43 // Return information about all the currently running workers. 44 virtual std::vector<WorkerInfo> GetWorkers() = 0; 45 46 virtual void AddObserver(WorkerServiceObserver* observer) = 0; 47 virtual void RemoveObserver(WorkerServiceObserver* observer) = 0; 48}; 49 50} // namespace content 51 52#endif // CONTENT_PUBLIC_BROWSER_PLUGIN_SERVICE_H_ 53