Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
16ae29b5
Commit
16ae29b5
authored
Jul 17, 2017
by
Carlo Bernaschina
Committed by
GitHub
Jul 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Register tools as a reloadSources service (#11229)" (#11256)
This reverts commit
35c49897
.
parent
35c49897
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
97 deletions
+8
-97
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+4
-15
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+1
-16
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+3
-66
No files found.
packages/flutter_tools/lib/src/resident_runner.dart
View file @
16ae29b5
...
...
@@ -44,20 +44,12 @@ class FlutterDevice {
_viewsCache
=
null
;
}
/// If the [reloadSources] parameter is not null the 'reloadSources' service
/// will be registered.
/// The 'reloadSources' service can be used by other Service Protocol clients
/// connected to the VM (e.g. Observatory) to request a reload of the source
/// code of the running application (a.k.a. HotReload).
/// This ensures that the reload process follows the normal orchestration of
/// the Flutter Tools and not just the VM internal service.
void
connect
({
ReloadSources
reloadSources
})
{
void
connect
()
{
if
(
vmServices
!=
null
)
return
;
vmServices
=
new
List
<
VMService
>(
observatoryUris
.
length
);
for
(
int
i
=
0
;
i
<
observatoryUris
.
length
;
i
++)
{
vmServices
[
i
]
=
VMService
.
connect
(
observatoryUris
[
i
],
reloadSources:
reloadSources
);
vmServices
[
i
]
=
VMService
.
connect
(
observatoryUris
[
i
]);
printTrace
(
'Connected to service protocol:
${observatoryUris[i]}
'
);
}
}
...
...
@@ -534,17 +526,14 @@ abstract class ResidentRunner {
device
.
stopEchoingDeviceLog
();
}
/// If the [reloadSources] parameter is not null the 'reloadSources' service
/// will be registered
Future
<
Null
>
connectToServiceProtocol
({
String
viewFilter
,
ReloadSources
reloadSources
})
async
{
Future
<
Null
>
connectToServiceProtocol
({
String
viewFilter
})
async
{
if
(!
debuggingOptions
.
debuggingEnabled
)
return
new
Future
<
Null
>.
error
(
'Error the service protocol is not enabled.'
);
bool
viewFound
=
false
;
for
(
FlutterDevice
device
in
flutterDevices
)
{
device
.
viewFilter
=
viewFilter
;
device
.
connect
(
reloadSources:
reloadSources
);
device
.
connect
();
await
device
.
getVMs
();
await
device
.
waitForViews
();
if
(
device
.
views
==
null
)
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
16ae29b5
...
...
@@ -16,8 +16,6 @@ import 'device.dart';
import
'globals.dart'
;
import
'resident_runner.dart'
;
import
'usage.dart'
;
import
'package:json_rpc_2/error_code.dart'
as
rpc_error_code
;
import
'package:json_rpc_2/json_rpc_2.dart'
as
rpc
;
import
'vmservice.dart'
;
class
HotRunnerConfig
{
...
...
@@ -85,26 +83,13 @@ class HotRunner extends ResidentRunner {
return
true
;
}
Future
<
Null
>
_reloadSourcesService
(
String
isolateId
,
{
bool
force:
false
,
bool
pause:
false
})
async
{
// TODO(cbernaschina): check that isolateId is the id of the UI isolate.
final
OperationResult
result
=
await
restart
(
pauseAfterRestart:
pause
);
if
(
result
!=
OperationResult
.
ok
)
{
throw
new
rpc
.
RpcException
(
rpc_error_code
.
INTERNAL_ERROR
,
'Unable to reload sources'
,
);
};
}
Future
<
int
>
attach
({
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
,
Completer
<
Null
>
appStartedCompleter
,
String
viewFilter
,
})
async
{
try
{
await
connectToServiceProtocol
(
viewFilter:
viewFilter
,
reloadSources:
_reloadSourcesService
);
await
connectToServiceProtocol
(
viewFilter:
viewFilter
);
}
catch
(
error
)
{
printError
(
'Error connecting to the service protocol:
$error
'
);
return
2
;
...
...
packages/flutter_tools/lib/src/vmservice.dart
View file @
16ae29b5
...
...
@@ -24,23 +24,6 @@ typedef StreamChannel<String> _OpenChannel(Uri uri);
_OpenChannel
_openChannel
=
_defaultOpenChannel
;
/// A function that reacts to the invocation of the 'reloadSources' service.
///
/// The VM Service Protocol allows clients to register custom services that
/// can be invoked by other clients through the service protocol itself.
///
/// Clients like Observatory use external 'reloadSources' services,
/// when available, instead of the VM internal one. This allows these clients to
/// invoke Flutter HotReload when connected to a Flutter Application started in
/// hot mode.
///
/// See: https://github.com/dart-lang/sdk/issues/30023
typedef
Future
<
Null
>
ReloadSources
(
String
isolateId
,
{
bool
force
,
bool
pause
,
});
const
String
_kRecordingType
=
'vmservice'
;
StreamChannel
<
String
>
_defaultOpenChannel
(
Uri
uri
)
=>
...
...
@@ -57,51 +40,13 @@ const Duration kShortRequestTimeout = const Duration(seconds: 5);
/// A connection to the Dart VM Service.
class
VMService
{
VMService
.
_
(
this
.
_peer
,
this
.
httpAddress
,
this
.
wsAddress
,
this
.
_requestTimeout
,
ReloadSources
reloadSources
,
)
{
VMService
.
_
(
this
.
_peer
,
this
.
httpAddress
,
this
.
wsAddress
,
this
.
_requestTimeout
)
{
_vm
=
new
VM
.
_empty
(
this
);
_peer
.
listen
().
catchError
(
_connectionError
.
completeError
);
_peer
.
registerMethod
(
'streamNotify'
,
(
rpc
.
Parameters
event
)
{
_handleStreamNotify
(
event
.
asMap
);
});
if
(
reloadSources
!=
null
)
{
_peer
.
registerMethod
(
'reloadSources'
,
(
rpc
.
Parameters
params
)
async
{
final
String
isolateId
=
params
[
'isolateId'
].
value
;
final
bool
force
=
params
.
asMap
[
'force'
]
??
false
;
final
bool
pause
=
params
.
asMap
[
'pause'
]
??
false
;
if
(
isolateId
is
!
String
||
isolateId
.
isEmpty
)
throw
new
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
isolateId
\'
:
$isolateId
'
);
if
(
force
is
!
bool
)
throw
new
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
force
\'
:
$force
'
);
if
(
pause
is
!
bool
)
throw
new
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
pause
\'
:
$pause
'
);
try
{
await
reloadSources
(
isolateId
,
force:
force
,
pause:
pause
);
return
{
'type'
:
'Success'
};
}
on
rpc
.
RpcException
{
rethrow
;
}
catch
(
e
,
st
)
{
throw
new
rpc
.
RpcException
(
rpc_error_code
.
SERVER_ERROR
,
'Error during Sources Reload:
$e
\n
$st
'
);
}
});
// If the Flutter Engine doesn't support service registration this will
// have no effect
_peer
.
sendNotification
(
'_registerService'
,
{
'service'
:
'reloadSources'
,
'alias'
:
'Flutter Tools'
});
}
}
/// Enables recording of VMService JSON-rpc activity to the specified base
...
...
@@ -131,24 +76,16 @@ class VMService {
/// Connect to a Dart VM Service at [httpUri].
///
/// Requests made via the return
ed
[VMService] time out after [requestTimeout]
/// Requests made via the return
s
[VMService] time out after [requestTimeout]
/// amount of time, which is [kDefaultRequestTimeout] by default.
///
/// If the [reloadSources] parameter is not null, the 'reloadSources' service
/// will be registered. The VM Service Protocol allows clients to register
/// custom services that can be invoked by other clients through the service
/// protocol itself.
///
/// See: https://github.com/dart-lang/sdk/commit/df8bf384eb815cf38450cb50a0f4b62230fba217
static
VMService
connect
(
Uri
httpUri
,
{
Duration
requestTimeout:
kDefaultRequestTimeout
,
ReloadSources
reloadSources
,
})
{
final
Uri
wsUri
=
httpUri
.
replace
(
scheme:
'ws'
,
path:
fs
.
path
.
join
(
httpUri
.
path
,
'ws'
));
final
StreamChannel
<
String
>
channel
=
_openChannel
(
wsUri
);
final
rpc
.
Peer
peer
=
new
rpc
.
Peer
.
withoutJson
(
jsonDocument
.
bind
(
channel
));
return
new
VMService
.
_
(
peer
,
httpUri
,
wsUri
,
requestTimeout
,
reloadSources
);
return
new
VMService
.
_
(
peer
,
httpUri
,
wsUri
,
requestTimeout
);
}
final
Uri
httpAddress
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment