| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/worker_host/worker_service.h" | 5 #include "content/browser/worker_host/worker_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 iter = pending_shared_workers_.erase(iter); | 215 iter = pending_shared_workers_.erase(iter); |
| 216 } else { | 216 } else { |
| 217 ++iter; | 217 ++iter; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool WorkerService::CreateWorkerFromInstance( | 222 bool WorkerService::CreateWorkerFromInstance( |
| 223 WorkerProcessHost::WorkerInstance instance) { | 223 WorkerProcessHost::WorkerInstance instance) { |
| 224 // TODO(michaeln): We need to ensure that a process is working | 224 // TODO(michaeln): We need to ensure that a process is working |
| 225 // on behalf of a single profile. The process sharing logic below | 225 // on behalf of a single context. The process sharing logic below |
| 226 // does not ensure that. Consider making WorkerService a per profile | 226 // does not ensure that. Consider making WorkerService a per context |
| 227 // object to help with this. | 227 // object to help with this. |
| 228 WorkerProcessHost* worker = NULL; | 228 WorkerProcessHost* worker = NULL; |
| 229 if (CommandLine::ForCurrentProcess()->HasSwitch( | 229 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 230 switches::kWebWorkerProcessPerCore)) { | 230 switches::kWebWorkerProcessPerCore)) { |
| 231 worker = GetProcessToFillUpCores(); | 231 worker = GetProcessToFillUpCores(); |
| 232 } else if (CommandLine::ForCurrentProcess()->HasSwitch( | 232 } else if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 233 switches::kWebWorkerShareProcesses)) { | 233 switches::kWebWorkerShareProcesses)) { |
| 234 worker = GetProcessForDomain(instance.url()); | 234 worker = GetProcessForDomain(instance.url()); |
| 235 } else { // One process per worker. | 235 } else { // One process per worker. |
| 236 if (!CanCreateWorkerProcess(instance)) { | 236 if (!CanCreateWorkerProcess(instance)) { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 WorkerProcessHost::WorkerInstance* instance = | 551 WorkerProcessHost::WorkerInstance* instance = |
| 552 FindPendingInstance(url, name, resource_context); | 552 FindPendingInstance(url, name, resource_context); |
| 553 if (instance) | 553 if (instance) |
| 554 return instance; | 554 return instance; |
| 555 | 555 |
| 556 // No existing pending worker - create a new one. | 556 // No existing pending worker - create a new one. |
| 557 WorkerProcessHost::WorkerInstance pending(url, true, name, resource_context); | 557 WorkerProcessHost::WorkerInstance pending(url, true, name, resource_context); |
| 558 pending_shared_workers_.push_back(pending); | 558 pending_shared_workers_.push_back(pending); |
| 559 return &pending_shared_workers_.back(); | 559 return &pending_shared_workers_.back(); |
| 560 } | 560 } |
| OLD | NEW |