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
8e765c7f
Unverified
Commit
8e765c7f
authored
May 18, 2020
by
Jonah Williams
Committed by
GitHub
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] put system clock on globals (#57447)
parent
49ad67cc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
19 deletions
+16
-19
time.dart
packages/flutter_tools/lib/src/base/time.dart
+0
-5
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+2
-3
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+4
-3
globals.dart
packages/flutter_tools/lib/src/globals.dart
+4
-0
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+1
-2
usage.dart
packages/flutter_tools/lib/src/reporting/usage.dart
+2
-2
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+3
-4
No files found.
packages/flutter_tools/lib/src/base/time.dart
View file @
8e765c7f
...
...
@@ -2,11 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'context.dart'
;
/// The current system clock instance.
SystemClock
get
systemClock
=>
context
.
get
<
SystemClock
>();
/// A class for making time based operations testable.
class
SystemClock
{
/// A const constructor to allow subclasses to be const.
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
8e765c7f
...
...
@@ -9,7 +9,6 @@ import 'package:args/command_runner.dart';
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/time.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../cache.dart'
;
...
...
@@ -428,7 +427,7 @@ class RunCommand extends RunCommandBase {
}
on
Exception
catch
(
error
)
{
throwToolExit
(
error
.
toString
());
}
final
DateTime
appStartedTime
=
systemClock
.
now
();
final
DateTime
appStartedTime
=
globals
.
systemClock
.
now
();
final
int
result
=
await
app
.
runner
.
waitForAppToFinish
();
if
(
result
!=
0
)
{
throwToolExit
(
null
,
exitCode:
result
);
...
...
@@ -553,7 +552,7 @@ class RunCommand extends RunCommandBase {
// This callback can't throw.
unawaited
(
appStartedTimeRecorder
.
future
.
then
<
void
>(
(
_
)
{
appStartedTime
=
systemClock
.
now
();
appStartedTime
=
globals
.
systemClock
.
now
();
if
(
stayResident
)
{
TerminalHandler
(
runner
)
..
setupTerminal
()
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
8e765c7f
...
...
@@ -54,13 +54,14 @@ Future<vm_service.VmService> _kDefaultFuchsiaIsolateDiscoveryConnector(Uri uri)
/// Read the log for a particular device.
class
_FuchsiaLogReader
extends
DeviceLogReader
{
_FuchsiaLogReader
(
this
.
_device
,
[
this
.
_app
]);
_FuchsiaLogReader
(
this
.
_device
,
this
.
_systemClock
,
[
this
.
_app
]);
// \S matches non-whitespace characters.
static
final
RegExp
_flutterLogOutput
=
RegExp
(
r'INFO: \S+\(flutter\): '
);
final
FuchsiaDevice
_device
;
final
ApplicationPackage
_app
;
final
SystemClock
_systemClock
;
@override
String
get
name
=>
_device
.
name
;
...
...
@@ -79,7 +80,7 @@ class _FuchsiaLogReader extends DeviceLogReader {
}
// Get the starting time of the log processor to filter logs from before
// the process attached.
final
DateTime
startTime
=
systemClock
.
now
();
final
DateTime
startTime
=
_
systemClock
.
now
();
// Determine if line comes from flutter, and optionally whether it matches
// the correct fuchsia module.
final
RegExp
matchRegExp
=
_app
==
null
...
...
@@ -534,7 +535,7 @@ class FuchsiaDevice extends Device {
bool
includePastLogs
=
false
,
})
{
assert
(!
includePastLogs
,
'Past log reading not supported on Fuchsia.'
);
return
_logReader
??=
_FuchsiaLogReader
(
this
,
app
);
return
_logReader
??=
_FuchsiaLogReader
(
this
,
globals
.
systemClock
,
app
);
}
_FuchsiaLogReader
_logReader
;
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
8e765c7f
...
...
@@ -20,6 +20,7 @@ import 'base/platform.dart';
import
'base/signals.dart'
;
import
'base/template.dart'
;
import
'base/terminal.dart'
;
import
'base/time.dart'
;
import
'base/user_messages.dart'
;
import
'build_system/build_system.dart'
;
import
'cache.dart'
;
...
...
@@ -107,6 +108,9 @@ BotDetector get botDetector => context.get<BotDetector>() ?? _defaultBotDetector
Future
<
bool
>
get
isRunningOnBot
=>
botDetector
.
isRunningOnBot
;
/// The current system clock instance.
SystemClock
get
systemClock
=>
context
.
get
<
SystemClock
>();
/// Display an error level message to the user. Commands should use this if they
/// fail in some way.
///
...
...
packages/flutter_tools/lib/src/plugins.dart
View file @
8e765c7f
...
...
@@ -11,7 +11,6 @@ import 'package:yaml/yaml.dart';
import
'android/gradle.dart'
;
import
'base/common.dart'
;
import
'base/file_system.dart'
;
import
'base/time.dart'
;
import
'convert.dart'
;
import
'dart/package_map.dart'
;
import
'features.dart'
;
...
...
@@ -423,7 +422,7 @@ bool _writeFlutterPluginsList(FlutterProject project, List<Plugin> plugins) {
/// should be removed once migration is complete.
/// https://github.com/flutter/flutter/issues/48918
result
[
'dependencyGraph'
]
=
_createPluginLegacyDependencyGraph
(
plugins
);
result
[
'date_created'
]
=
systemClock
.
now
().
toString
();
result
[
'date_created'
]
=
globals
.
systemClock
.
now
().
toString
();
result
[
'version'
]
=
globals
.
flutterVersion
.
frameworkVersion
;
// Only notify if the plugins list has changed. [date_created] will always be different,
...
...
packages/flutter_tools/lib/src/reporting/usage.dart
View file @
8e765c7f
...
...
@@ -306,7 +306,7 @@ class _DefaultUsage implements Usage {
final
Map
<
String
,
String
>
paramsWithLocalTime
=
<
String
,
String
>{
...?
parameters
,
cdKey
(
CustomDimensions
.
localTime
):
formatDateTime
(
systemClock
.
now
()),
cdKey
(
CustomDimensions
.
localTime
):
formatDateTime
(
globals
.
systemClock
.
now
()),
};
_analytics
.
sendScreenView
(
command
,
parameters:
paramsWithLocalTime
);
}
...
...
@@ -325,7 +325,7 @@ class _DefaultUsage implements Usage {
final
Map
<
String
,
String
>
paramsWithLocalTime
=
<
String
,
String
>{
...?
parameters
,
cdKey
(
CustomDimensions
.
localTime
):
formatDateTime
(
systemClock
.
now
()),
cdKey
(
CustomDimensions
.
localTime
):
formatDateTime
(
globals
.
systemClock
.
now
()),
};
_analytics
.
sendEvent
(
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
8e765c7f
...
...
@@ -15,7 +15,6 @@ import '../base/common.dart';
import
'../base/context.dart'
;
import
'../base/io.dart'
as
io
;
import
'../base/signals.dart'
;
import
'../base/time.dart'
;
import
'../base/user_messages.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
...
...
@@ -680,7 +679,7 @@ abstract class FlutterCommand extends Command<void> {
/// so that this method can record and report the overall time to analytics.
@override
Future
<
void
>
run
()
{
final
DateTime
startTime
=
systemClock
.
now
();
final
DateTime
startTime
=
globals
.
systemClock
.
now
();
return
context
.
run
<
void
>(
name:
'command'
,
...
...
@@ -694,7 +693,7 @@ abstract class FlutterCommand extends Command<void> {
try
{
commandResult
=
await
verifyThenRunCommand
(
commandPath
);
}
finally
{
final
DateTime
endTime
=
systemClock
.
now
();
final
DateTime
endTime
=
globals
.
systemClock
.
now
();
globals
.
printTrace
(
userMessages
.
flutterElapsedTime
(
name
,
getElapsedAsMilliseconds
(
endTime
.
difference
(
startTime
))));
_sendPostUsage
(
commandPath
,
commandResult
,
startTime
,
endTime
);
}
...
...
@@ -709,7 +708,7 @@ abstract class FlutterCommand extends Command<void> {
commandPath
,
const
FlutterCommandResult
(
ExitStatus
.
killed
),
startTime
,
systemClock
.
now
(),
globals
.
systemClock
.
now
(),
);
};
globals
.
signals
.
addHandler
(
io
.
ProcessSignal
.
SIGTERM
,
handler
);
...
...
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