4
4
//! <https://chromedevtools.github.io/devtools-protocol/>
5
5
//! <https://hyperandroid.com/2020/02/12/v8-inspector-from-an-embedder-standpoint/>
6
6
7
- use crate :: error:: CoreError ;
8
- use crate :: error:: CoreErrorKind ;
9
7
use crate :: futures:: channel:: mpsc;
10
8
use crate :: futures:: channel:: mpsc:: UnboundedReceiver ;
11
9
use crate :: futures:: channel:: mpsc:: UnboundedSender ;
@@ -16,8 +14,6 @@ use crate::futures::stream::StreamExt;
16
14
use crate :: futures:: task;
17
15
use crate :: serde_json:: json;
18
16
19
- use boxed_error:: Boxed ;
20
- use deno_error:: JsErrorBox ;
21
17
use parking_lot:: Mutex ;
22
18
use std:: cell:: RefCell ;
23
19
use std:: collections:: HashMap ;
@@ -30,7 +26,6 @@ use std::sync::Arc;
30
26
use std:: task:: Context ;
31
27
use std:: task:: Poll ;
32
28
use std:: thread;
33
- use thiserror:: Error ;
34
29
35
30
#[ derive( Debug ) ]
36
31
pub enum InspectorMsgKind {
@@ -54,7 +49,7 @@ pub type SessionProxyReceiver = UnboundedReceiver<String>;
54
49
pub struct InspectorSessionProxy {
55
50
pub tx : SessionProxySender ,
56
51
pub rx : SessionProxyReceiver ,
57
- pub options : InspectorSessionOptions ,
52
+ pub kind : InspectorSessionKind ,
58
53
}
59
54
60
55
pub type InspectorSessionSend = Box < dyn Fn ( InspectorMsg ) > ;
@@ -213,7 +208,7 @@ impl JsRuntimeInspectorState {
213
208
let _ = session_proxy. tx . unbounded_send ( msg) ;
214
209
} ) ,
215
210
Some ( session_proxy. rx ) ,
216
- session_proxy. options ,
211
+ session_proxy. kind ,
217
212
) ;
218
213
let prev = sessions. handshake . replace ( session) ;
219
214
assert ! ( prev. is_none( ) ) ;
@@ -453,7 +448,7 @@ impl JsRuntimeInspector {
453
448
pub fn create_local_session (
454
449
inspector : Rc < JsRuntimeInspector > ,
455
450
callback : InspectorSessionSend ,
456
- options : InspectorSessionOptions ,
451
+ kind : InspectorSessionKind ,
457
452
) -> LocalInspectorSession {
458
453
let ( session_id, sessions) = {
459
454
let sessions = inspector. state . sessions . clone ( ) ;
@@ -463,7 +458,7 @@ impl JsRuntimeInspector {
463
458
inspector. state . is_dispatching_message . clone ( ) ,
464
459
callback,
465
460
None ,
466
- options ,
461
+ kind ,
467
462
) ;
468
463
469
464
let session_id = {
@@ -482,11 +477,6 @@ impl JsRuntimeInspector {
482
477
}
483
478
}
484
479
485
- #[ derive( Debug ) ]
486
- pub struct InspectorSessionOptions {
487
- pub kind : InspectorSessionKind ,
488
- }
489
-
490
480
#[ derive( Default ) ]
491
481
struct InspectorFlags {
492
482
waiting_for_session : bool ,
@@ -694,13 +684,13 @@ impl InspectorSession {
694
684
is_dispatching_message : Rc < RefCell < bool > > ,
695
685
send : InspectorSessionSend ,
696
686
rx : Option < SessionProxyReceiver > ,
697
- options : InspectorSessionOptions ,
687
+ kind : InspectorSessionKind ,
698
688
) -> Rc < Self > {
699
689
let state = InspectorSessionState {
700
690
is_dispatching_message,
701
691
send : Rc :: new ( send) ,
702
692
rx : Rc :: new ( RefCell :: new ( rx) ) ,
703
- kind : options . kind ,
693
+ kind,
704
694
} ;
705
695
706
696
let v8_session = v8_inspector. connect (
@@ -772,34 +762,6 @@ async fn pump_inspector_session_messages(session: Rc<InspectorSession>) {
772
762
}
773
763
}
774
764
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
-
803
765
/// A local inspector session that can be used to send and receive protocol messages directly on
804
766
/// the same thread as an isolate.
805
767
///
0 commit comments