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" |
11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "content/browser/resource_context.h" | 13 #include "content/browser/resource_context.h" |
14 #include "content/browser/worker_host/worker_message_filter.h" | 14 #include "content/browser/worker_host/worker_message_filter.h" |
15 #include "content/browser/worker_host/worker_process_host.h" | 15 #include "content/browser/worker_host/worker_process_host.h" |
16 #include "content/browser/worker_host/worker_service_observer.h" | 16 #include "content/browser/worker_host/worker_service_observer.h" |
17 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
18 #include "content/common/worker_messages.h" | 18 #include "content/common/worker_messages.h" |
19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
20 #include "net/base/registry_controlled_domain.h" | 20 #include "net/base/registry_controlled_domain.h" |
21 | 21 |
| 22 using content::BrowserThread; |
| 23 |
22 const int WorkerService::kMaxWorkerProcessesWhenSharing = 10; | 24 const int WorkerService::kMaxWorkerProcessesWhenSharing = 10; |
23 const int WorkerService::kMaxWorkersWhenSeparate = 64; | 25 const int WorkerService::kMaxWorkersWhenSeparate = 64; |
24 const int WorkerService::kMaxWorkersPerTabWhenSeparate = 16; | 26 const int WorkerService::kMaxWorkersPerTabWhenSeparate = 16; |
25 | 27 |
26 WorkerService* WorkerService::GetInstance() { | 28 WorkerService* WorkerService::GetInstance() { |
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
28 return Singleton<WorkerService>::get(); | 30 return Singleton<WorkerService>::get(); |
29 } | 31 } |
30 | 32 |
31 WorkerService::WorkerService() : next_worker_route_id_(0) { | 33 WorkerService::WorkerService() : next_worker_route_id_(0) { |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 WorkerProcessHost::WorkerInstance* instance = | 549 WorkerProcessHost::WorkerInstance* instance = |
548 FindPendingInstance(url, name, resource_context); | 550 FindPendingInstance(url, name, resource_context); |
549 if (instance) | 551 if (instance) |
550 return instance; | 552 return instance; |
551 | 553 |
552 // No existing pending worker - create a new one. | 554 // No existing pending worker - create a new one. |
553 WorkerProcessHost::WorkerInstance pending(url, true, name, resource_context); | 555 WorkerProcessHost::WorkerInstance pending(url, true, name, resource_context); |
554 pending_shared_workers_.push_back(pending); | 556 pending_shared_workers_.push_back(pending); |
555 return &pending_shared_workers_.back(); | 557 return &pending_shared_workers_.back(); |
556 } | 558 } |
OLD | NEW |