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

Side by Side Diff: content/browser/worker_host/worker_service_impl.h

Issue 411283002: Remove disable-embedded-shared-worker flag and shared worker process related codes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 4 months 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 unified diff | Download patch
OLDNEW
(Empty)
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_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/singleton.h"
11 #include "base/observer_list.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "content/browser/worker_host/worker_process_host.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/worker_service.h"
17
18 class GURL;
19 struct ViewHostMsg_CreateWorker_Params;
20
21 namespace content {
22 class ResourceContext;
23 class WorkerServiceObserver;
24 class WorkerStoragePartition;
25 class WorkerPrioritySetter;
26
27 class CONTENT_EXPORT WorkerServiceImpl
28 : public NON_EXPORTED_BASE(WorkerService) {
29 public:
30 // Returns the WorkerServiceImpl singleton.
31 static WorkerServiceImpl* GetInstance();
32
33 // Releases the priority setter to avoid memory leak error.
34 void PerformTeardownForTesting();
35
36 // WorkerService implementation:
37 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE;
38 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE;
39 virtual void AddObserver(WorkerServiceObserver* observer) OVERRIDE;
40 virtual void RemoveObserver(WorkerServiceObserver* observer) OVERRIDE;
41
42 // These methods correspond to worker related IPCs.
43 void CreateWorker(const ViewHostMsg_CreateWorker_Params& params,
44 int route_id,
45 WorkerMessageFilter* filter,
46 ResourceContext* resource_context,
47 const WorkerStoragePartition& worker_partition,
48 bool* url_mismatch);
49 void ForwardToWorker(const IPC::Message& message,
50 WorkerMessageFilter* filter);
51 void DocumentDetached(unsigned long long document_id,
52 WorkerMessageFilter* filter);
53
54 void OnWorkerMessageFilterClosing(WorkerMessageFilter* filter);
55
56 int next_worker_route_id() { return ++next_worker_route_id_; }
57
58 // Given a worker's process id, return the IDs of the renderer process and
59 // render frame that created it. For shared workers, this returns the first
60 // parent.
61 // TODO(dimich): This code assumes there is 1 worker per worker process, which
62 // is how it is today until V8 can run in separate threads.
63 bool GetRendererForWorker(int worker_process_id,
64 int* render_process_id,
65 int* render_frame_id) const;
66 const WorkerProcessHost::WorkerInstance* FindWorkerInstance(
67 int worker_process_id);
68
69 void NotifyWorkerDestroyed(
70 WorkerProcessHost* process,
71 int worker_route_id);
72
73 void NotifyWorkerProcessCreated();
74
75 // Used when we run each worker in a separate process.
76 static const int kMaxWorkersWhenSeparate;
77 static const int kMaxWorkersPerFrameWhenSeparate;
78
79 private:
80 friend struct DefaultSingletonTraits<WorkerServiceImpl>;
81
82 WorkerServiceImpl();
83 virtual ~WorkerServiceImpl();
84
85 // Given a WorkerInstance, create an associated worker process.
86 bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance);
87
88 // Checks if we can create a worker process based on the process limit when
89 // we're using a strategy of one process per core.
90 bool CanCreateWorkerProcess(
91 const WorkerProcessHost::WorkerInstance& instance);
92
93 // Checks if the frame associated with the passed RenderFrame can create a
94 // worker process based on the process limit when we're using a strategy of
95 // one worker per process.
96 bool FrameCanCreateWorkerProcess(
97 int render_process_id, int render_frame_id, bool* hit_total_worker_limit);
98
99 // Tries to see if any of the queued workers can be created.
100 void TryStartingQueuedWorker();
101
102 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance(
103 const GURL& url,
104 const base::string16& name,
105 const WorkerStoragePartition& worker_partition,
106 ResourceContext* resource_context);
107
108 scoped_refptr<WorkerPrioritySetter> priority_setter_;
109
110 int next_worker_route_id_;
111
112 WorkerProcessHost::Instances queued_workers_;
113
114 ObserverList<WorkerServiceObserver> observers_;
115
116 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl);
117 };
118
119 } // namespace content
120
121 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
OLDNEW
« no previous file with comments | « content/browser/worker_host/worker_process_host.cc ('k') | content/browser/worker_host/worker_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698