agents/skills/browser-window-feature-refactor/references/bwf-ordering.md
BrowserWindowFeatures ordering is intentionally structured. Preserve the
current layout when adding or moving feature ownership.
In browser_window_features.h:
#include their headers here. std::unique_ptr<T> and raw_ptr<T> members
only need a forward declaration of T, so add class FooController; to the
forward-declaration block and put the controller's #include in
browser_window_features.cc instead. This keeps the aggregator header
dependency-light. When you add a new BWF-owned controller, follow the existing
pattern in the file rather than including the new controller's header.UnownedUserData for new
feature access.Do not mechanically alphabetize private members. Declaration order controls destruction order, so changes require dependency review.
Private members are grouped by ownership:
BrowserView is attached;WebUIBrowserWindow is used;Within a group, keep related dependency clusters together. If a member must be
out of alphabetical position, add or preserve a Must be before or
Must be after comment.
New BWF-owned controllers must make their dependencies explicit when ordering
matters. Construct them through
GetUserDataFactory().CreateInstance<FooController>(*browser, ...) (which
returns a std::unique_ptr<>), not std::make_unique. Put the dependency
comment next to the member declaration or the initialization site, following the
local style:
// Must be after session_service_browser_helper_:
// tab_list_bridge_ depends on initialized session tab/window state.
tab_list_bridge_ =
GetUserDataFactory().CreateInstance<TabListBridge>(*browser, ...);
For a new FooWindowController, call out both directions when relevant:
foo_window_controller_ depends on;foo_window_controller_ being initialized.The three lifecycle methods follow a consistent layout:
TYPE_NORMAL browser windows.Dependency ordering takes precedence over alphabetical ordering. Important ordering constraints should be called out inline.
TearDownPreBrowserWindowDestruction() tears down in reverse order of the
construction lifecycle:
InitPostWindowConstruction() members;Init() members.Within each section, reset members in reverse of the corresponding initialization order unless a dependency comment explains a different order.