Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: content/browser/worker_host/worker_service.h

Issue 9052007: Create an API around WorkerService that chrome consumes. Rename the existing WorkerService to Wor... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/worker_host/worker_process_host.cc ('k') | content/browser/worker_host/worker_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/worker_host/worker_service.h
===================================================================
--- content/browser/worker_host/worker_service.h (revision 115981)
+++ content/browser/worker_host/worker_service.h (working copy)
@@ -1,149 +0,0 @@
-// Copyright (c) 2011 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_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
-#define CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/memory/singleton.h"
-#include "base/observer_list.h"
-#include "base/threading/non_thread_safe.h"
-#include "content/browser/worker_host/worker_process_host.h"
-#include "content/common/content_export.h"
-#include "content/public/browser/notification_registrar.h"
-#include "googleurl/src/gurl.h"
-
-struct ViewHostMsg_CreateWorker_Params;
-class WorkerServiceObserver;
-
-namespace content {
-class ResourceContext;
-} // namespace content
-
-// A singleton for managing HTML5 web workers.
-class CONTENT_EXPORT WorkerService {
- public:
- // Returns the WorkerService singleton.
- static WorkerService* GetInstance();
-
- // These methods correspond to worker related IPCs.
- void CreateWorker(const ViewHostMsg_CreateWorker_Params& params,
- int route_id,
- WorkerMessageFilter* filter,
- const content::ResourceContext& resource_context);
- void LookupSharedWorker(const ViewHostMsg_CreateWorker_Params& params,
- int route_id,
- WorkerMessageFilter* filter,
- const content::ResourceContext* resource_context,
- bool* exists,
- bool* url_error);
- void CancelCreateDedicatedWorker(int route_id, WorkerMessageFilter* filter);
- void ForwardToWorker(const IPC::Message& message,
- WorkerMessageFilter* filter);
- void DocumentDetached(unsigned long long document_id,
- WorkerMessageFilter* filter);
-
- void OnWorkerMessageFilterClosing(WorkerMessageFilter* filter);
-
- int next_worker_route_id() { return ++next_worker_route_id_; }
-
- // Given a worker's process id, return the IDs of the renderer process and
- // render view that created it. For shared workers, this returns the first
- // parent.
- // TODO(dimich): This code assumes there is 1 worker per worker process, which
- // is how it is today until V8 can run in separate threads.
- bool GetRendererForWorker(int worker_process_id,
- int* render_process_id,
- int* render_view_id) const;
- const WorkerProcessHost::WorkerInstance* FindWorkerInstance(
- int worker_process_id);
-
- void AddObserver(WorkerServiceObserver* observer);
- void RemoveObserver(WorkerServiceObserver* observer);
-
- void NotifyWorkerDestroyed(
- WorkerProcessHost* process,
- int worker_route_id);
- void NotifyWorkerContextStarted(
- WorkerProcessHost* process,
- int worker_route_id);
-
- // Used when multiple workers can run in the same process.
- static const int kMaxWorkerProcessesWhenSharing;
-
- // Used when we run each worker in a separate process.
- static const int kMaxWorkersWhenSeparate;
- static const int kMaxWorkersPerTabWhenSeparate;
-
- private:
- friend struct DefaultSingletonTraits<WorkerService>;
-
- WorkerService();
- ~WorkerService();
-
- // Given a WorkerInstance, create an associated worker process.
- bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance);
-
- // Returns a WorkerProcessHost object if one exists for the given domain, or
- // NULL if there are no such workers yet.
- WorkerProcessHost* GetProcessForDomain(const GURL& url);
-
- // Returns a WorkerProcessHost based on a strategy of creating one worker per
- // core.
- WorkerProcessHost* GetProcessToFillUpCores();
-
- // Returns the WorkerProcessHost from the existing set that has the least
- // number of worker instance running.
- WorkerProcessHost* GetLeastLoadedWorker();
-
- // Checks if we can create a worker process based on the process limit when
- // we're using a strategy of one process per core.
- bool CanCreateWorkerProcess(
- const WorkerProcessHost::WorkerInstance& instance);
-
- // Checks if the tab associated with the passed RenderView can create a
- // worker process based on the process limit when we're using a strategy of
- // one worker per process.
- bool TabCanCreateWorkerProcess(
- int render_process_id, int render_route_id, bool* hit_total_worker_limit);
-
- // Tries to see if any of the queued workers can be created.
- void TryStartingQueuedWorker();
-
- // APIs for manipulating our set of pending shared worker instances.
- WorkerProcessHost::WorkerInstance* CreatePendingInstance(
- const GURL& url,
- const string16& name,
- const content::ResourceContext* resource_context);
- WorkerProcessHost::WorkerInstance* FindPendingInstance(
- const GURL& url,
- const string16& name,
- const content::ResourceContext* resource_context);
- void RemovePendingInstances(
- const GURL& url,
- const string16& name,
- const content::ResourceContext* resource_context);
-
- WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance(
- const GURL& url,
- const string16& name,
- const content::ResourceContext* resource_context);
-
- content::NotificationRegistrar registrar_;
- int next_worker_route_id_;
-
- WorkerProcessHost::Instances queued_workers_;
-
- // These are shared workers that have been looked up, but not created yet.
- // We need to keep a list of these to synchronously detect shared worker
- // URL mismatches when two pages launch shared workers simultaneously.
- WorkerProcessHost::Instances pending_shared_workers_;
-
- ObserverList<WorkerServiceObserver> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(WorkerService);
-};
-
-#endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
« no previous file with comments | « content/browser/worker_host/worker_process_host.cc ('k') | content/browser/worker_host/worker_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698