| 
									
										
										
										
											2017-03-07 19:35:03 +09:00
										 |  |  | // Copyright (c) 2017 GitHub, Inc.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be
 | 
					
						
							|  |  |  | // found in the LICENSE file.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef ATOM_RENDERER_WEB_WORKER_OBSERVER_H_
 | 
					
						
							|  |  |  | #define ATOM_RENDERER_WEB_WORKER_OBSERVER_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 19:25:56 -05:00
										 |  |  | #include <memory>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-07 19:35:03 +09:00
										 |  |  | #include "base/macros.h"
 | 
					
						
							|  |  |  | #include "v8/include/v8.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace atom { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-18 12:37:06 -07:00
										 |  |  | class ElectronBindings; | 
					
						
							| 
									
										
										
										
											2017-03-07 19:35:03 +09:00
										 |  |  | class NodeBindings; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Watches for WebWorker and insert node integration to it.
 | 
					
						
							|  |  |  | class WebWorkerObserver { | 
					
						
							|  |  |  |  public: | 
					
						
							|  |  |  |   // Returns the WebWorkerObserver for current worker thread.
 | 
					
						
							|  |  |  |   static WebWorkerObserver* GetCurrent(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void ContextCreated(v8::Local<v8::Context> context); | 
					
						
							|  |  |  |   void ContextWillDestroy(v8::Local<v8::Context> context); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  private: | 
					
						
							|  |  |  |   WebWorkerObserver(); | 
					
						
							|  |  |  |   ~WebWorkerObserver(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   std::unique_ptr<NodeBindings> node_bindings_; | 
					
						
							| 
									
										
										
										
											2019-03-18 12:37:06 -07:00
										 |  |  |   std::unique_ptr<ElectronBindings> electron_bindings_; | 
					
						
							| 
									
										
										
										
											2017-03-07 19:35:03 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  |   DISALLOW_COPY_AND_ASSIGN(WebWorkerObserver); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }  // namespace atom
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif  // ATOM_RENDERER_WEB_WORKER_OBSERVER_H_
 |