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

Side by Side Diff: chrome/browser/worker_host/worker_service.h

Issue 63036: Fix a crash where the ResourceMessageFilter is deleted (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_WORKER_HOST__WORKER_SERVICE_H_ 5 #ifndef CHROME_BROWSER_WORKER_HOST__WORKER_SERVICE_H_
6 #define CHROME_BROWSER_WORKER_HOST__WORKER_SERVICE_H_ 6 #define CHROME_BROWSER_WORKER_HOST__WORKER_SERVICE_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/singleton.h" 11 #include "base/singleton.h"
12 #include "chrome/common/notification_observer.h"
12 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
13 14
14 namespace IPC { 15 namespace IPC {
15 class Message; 16 class Message;
16 } 17 }
17 18
18 class MessageLoop; 19 class MessageLoop;
19 class WorkerProcessHost; 20 class WorkerProcessHost;
20 class ResourceMessageFilter; 21 class ResourceMessageFilter;
21 22
22 class WorkerService { 23 class WorkerService : public NotificationObserver {
23 public: 24 public:
24 // Returns the WorkerService singleton. 25 // Returns the WorkerService singleton.
25 static WorkerService* GetInstance(); 26 static WorkerService* GetInstance();
26 27
27 // Creates a dedicated worker. Returns true on success. 28 // Creates a dedicated worker. Returns true on success.
28 bool CreateDedicatedWorker(const GURL &url, 29 bool CreateDedicatedWorker(const GURL &url,
29 int render_view_route_id, 30 int render_view_route_id,
30 ResourceMessageFilter* filter, 31 ResourceMessageFilter* filter,
31 int renderer_route_id); 32 int renderer_route_id);
32 33
33 // Called by ResourceMessageFilter when a message from the renderer comes that 34 // Called by ResourceMessageFilter when a message from the renderer comes that
34 // should be forwarded to the worker process. 35 // should be forwarded to the worker process.
35 void ForwardMessage(const IPC::Message& message); 36 void ForwardMessage(const IPC::Message& message);
36 37
37 // Called by ResourceMessageFilter when it's destructed so that all the 38 // NotificationObserver interface.
38 // WorkerProcessHost objects can remove their pointers to it. 39 void Observe(NotificationType type,
39 void RendererShutdown(ResourceMessageFilter* filter); 40 const NotificationSource& source,
41 const NotificationDetails& details);
40 42
41 private: 43 private:
42 friend struct DefaultSingletonTraits<WorkerService>; 44 friend struct DefaultSingletonTraits<WorkerService>;
43 45
44 WorkerService(); 46 WorkerService();
45 ~WorkerService(); 47 ~WorkerService();
46 48
47 // Returns a WorkerProcessHost object if one exists for the given domain, or 49 // Returns a WorkerProcessHost object if one exists for the given domain, or
48 // NULL if there are no such workers yet. 50 // NULL if there are no such workers yet.
49 WorkerProcessHost* GetProcessForDomain(const GURL& url); 51 WorkerProcessHost* GetProcessForDomain(const GURL& url);
50 52
51 // Returns a WorkerProcessHost based on a strategy of creating one worker per 53 // Returns a WorkerProcessHost based on a strategy of creating one worker per
52 // core. 54 // core.
53 WorkerProcessHost* GetProcessToFillUpCores(); 55 WorkerProcessHost* GetProcessToFillUpCores();
54 56
55 // Returns the WorkerProcessHost from the existing set that has the least 57 // Returns the WorkerProcessHost from the existing set that has the least
56 // number of worker instance running. 58 // number of worker instance running.
57 WorkerProcessHost* GetLeastLoadedWorker(); 59 WorkerProcessHost* GetLeastLoadedWorker();
58 60
59 int next_worker_route_id_; 61 int next_worker_route_id_;
60 62
61 DISALLOW_COPY_AND_ASSIGN(WorkerService); 63 DISALLOW_COPY_AND_ASSIGN(WorkerService);
62 }; 64 };
63 65
64 #endif // CHROME_BROWSER_WORKER_HOST__WORKER_SERVICE_H_ 66 #endif // CHROME_BROWSER_WORKER_HOST__WORKER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698