44//! <https://chromedevtools.github.io/devtools-protocol/>
55//! <https://hyperandroid.com/2020/02/12/v8-inspector-from-an-embedder-standpoint/>
66
7- use crate :: error:: CoreError ;
8- use crate :: error:: CoreErrorKind ;
97use crate :: futures:: channel:: mpsc;
108use crate :: futures:: channel:: mpsc:: UnboundedReceiver ;
119use crate :: futures:: channel:: mpsc:: UnboundedSender ;
@@ -16,8 +14,6 @@ use crate::futures::stream::StreamExt;
1614use crate :: futures:: task;
1715use crate :: serde_json:: json;
1816
19- use boxed_error:: Boxed ;
20- use deno_error:: JsErrorBox ;
2117use parking_lot:: Mutex ;
2218use std:: cell:: RefCell ;
2319use std:: collections:: HashMap ;
@@ -30,7 +26,6 @@ use std::sync::Arc;
3026use std:: task:: Context ;
3127use std:: task:: Poll ;
3228use std:: thread;
33- use thiserror:: Error ;
3429
3530#[ derive( Debug ) ]
3631pub enum InspectorMsgKind {
@@ -54,7 +49,7 @@ pub type SessionProxyReceiver = UnboundedReceiver<String>;
5449pub struct InspectorSessionProxy {
5550 pub tx : SessionProxySender ,
5651 pub rx : SessionProxyReceiver ,
57- pub options : InspectorSessionOptions ,
52+ pub kind : InspectorSessionKind ,
5853}
5954
6055pub type InspectorSessionSend = Box < dyn Fn ( InspectorMsg ) > ;
@@ -213,7 +208,7 @@ impl JsRuntimeInspectorState {
213208 let _ = session_proxy. tx . unbounded_send ( msg) ;
214209 } ) ,
215210 Some ( session_proxy. rx ) ,
216- session_proxy. options ,
211+ session_proxy. kind ,
217212 ) ;
218213 let prev = sessions. handshake . replace ( session) ;
219214 assert ! ( prev. is_none( ) ) ;
@@ -453,7 +448,7 @@ impl JsRuntimeInspector {
453448 pub fn create_local_session (
454449 inspector : Rc < JsRuntimeInspector > ,
455450 callback : InspectorSessionSend ,
456- options : InspectorSessionOptions ,
451+ kind : InspectorSessionKind ,
457452 ) -> LocalInspectorSession {
458453 let ( session_id, sessions) = {
459454 let sessions = inspector. state . sessions . clone ( ) ;
@@ -463,7 +458,7 @@ impl JsRuntimeInspector {
463458 inspector. state . is_dispatching_message . clone ( ) ,
464459 callback,
465460 None ,
466- options ,
461+ kind ,
467462 ) ;
468463
469464 let session_id = {
@@ -482,11 +477,6 @@ impl JsRuntimeInspector {
482477 }
483478}
484479
485- #[ derive( Debug ) ]
486- pub struct InspectorSessionOptions {
487- pub kind : InspectorSessionKind ,
488- }
489-
490480#[ derive( Default ) ]
491481struct InspectorFlags {
492482 waiting_for_session : bool ,
@@ -694,13 +684,13 @@ impl InspectorSession {
694684 is_dispatching_message : Rc < RefCell < bool > > ,
695685 send : InspectorSessionSend ,
696686 rx : Option < SessionProxyReceiver > ,
697- options : InspectorSessionOptions ,
687+ kind : InspectorSessionKind ,
698688 ) -> Rc < Self > {
699689 let state = InspectorSessionState {
700690 is_dispatching_message,
701691 send : Rc :: new ( send) ,
702692 rx : Rc :: new ( RefCell :: new ( rx) ) ,
703- kind : options . kind ,
693+ kind,
704694 } ;
705695
706696 let v8_session = v8_inspector. connect (
@@ -772,34 +762,6 @@ async fn pump_inspector_session_messages(session: Rc<InspectorSession>) {
772762 }
773763}
774764
775- #[ derive( Debug , Boxed ) ]
776- pub struct InspectorPostMessageError ( pub Box < InspectorPostMessageErrorKind > ) ;
777-
778- #[ derive( Debug , Error ) ]
779- pub enum InspectorPostMessageErrorKind {
780- #[ error( transparent) ]
781- JsBox ( #[ from] JsErrorBox ) ,
782- #[ error( transparent) ]
783- FutureCanceled ( futures:: channel:: oneshot:: Canceled ) ,
784- }
785-
786- impl From < InspectorPostMessageError > for CoreError {
787- fn from ( value : InspectorPostMessageError ) -> Self {
788- CoreErrorKind :: JsBox ( value. into_js_error_box ( ) ) . into_box ( )
789- }
790- }
791-
792- impl InspectorPostMessageError {
793- pub fn into_js_error_box ( self ) -> JsErrorBox {
794- match self . into_kind ( ) {
795- InspectorPostMessageErrorKind :: JsBox ( e) => e,
796- InspectorPostMessageErrorKind :: FutureCanceled ( e) => {
797- JsErrorBox :: generic ( e. to_string ( ) )
798- }
799- }
800- }
801- }
802-
803765/// A local inspector session that can be used to send and receive protocol messages directly on
804766/// the same thread as an isolate.
805767///
0 commit comments