-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize chart pane controller code and prepare structure for offli…
…ne mode. (#7572)
- Loading branch information
Showing
29 changed files
with
500 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/devtools_app/lib/src/screens/memory/framework/offline_data/offline_data.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2024 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import '../../panes/chart/controller/chart_pane_controller.dart'; | ||
import '../../panes/diff/controller/diff_pane_controller.dart'; | ||
import '../../panes/profile/profile_pane_controller.dart'; | ||
import '../../shared/heap/class_filter.dart'; | ||
|
||
class _Json { | ||
static const selectedTab = 'selectedTab'; | ||
static const classFilter = 'classFilter'; | ||
static const diffData = 'diffData'; | ||
static const profileData = 'profileData'; | ||
static const chartData = 'chartData'; | ||
} | ||
|
||
class OfflineMemoryData { | ||
OfflineMemoryData( | ||
this.diff, | ||
this.profile, | ||
this.chart, | ||
this.filter, { | ||
required this.selectedTab, | ||
}); | ||
|
||
// TODO(polina-c): use an extension type for the Json parsing, https://github.com/flutter/devtools/issues/6972 | ||
// https://github.com/flutter/devtools/pull/7572#discussion_r1563102256 | ||
factory OfflineMemoryData.parse(Map<String, dynamic> json) { | ||
Map<String, dynamic> item(String key) => | ||
json[key] as Map<String, dynamic>? ?? {}; | ||
return OfflineMemoryData( | ||
DiffPaneController.parse(item(_Json.diffData)), | ||
ProfilePaneController.parse(item(_Json.profileData)), | ||
MemoryChartPaneController.parse(item(_Json.chartData)), | ||
ClassFilter.parse(item(_Json.classFilter)), | ||
selectedTab: json[_Json.selectedTab] as int? ?? 0, | ||
); | ||
} | ||
|
||
final int selectedTab; | ||
final ClassFilter filter; // filter is shared between tabs, so it's here | ||
|
||
final DiffPaneController diff; | ||
final ProfilePaneController profile; | ||
final MemoryChartPaneController chart; | ||
|
||
Map<String, dynamic> prepareForOffline() { | ||
return { | ||
_Json.selectedTab: selectedTab, | ||
_Json.diffData: diff.prepareForOffline(), | ||
_Json.profileData: profile.prepareForOffline(), | ||
_Json.chartData: chart.prepareForOffline(), | ||
_Json.classFilter: profile.classFilter.value.prepareForOffline(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.