The automatic stream detection system will identify and classify data streams from multiple sources:
- DOM elements that update regularly (stock prices, scores, counters)
- Repeated network requests to the same endpoints
- Parameterized filtering (e.g., requests where
location=USA) - WebSocket message streams
1. Directory Structure
components/datasipper/streaming/
├── stream_types.h ✓ Complete (270 lines)
├── stream_types.cc ✓ Complete (220 lines)
├── dom_mutation_tracker.js ✓ Complete (330 lines)
├── dom_stream_tracker.h ✓ Complete (80 lines)
├── dom_stream_tracker.cc ✓ Complete (320 lines)
└── BUILD.gn ✓ Complete (50 lines)
Total Code: ~1,270 lines of production-ready code
2. Core Data Structures (stream_types.{h,cc})
-
Stream Types:
StreamType: DOM_MUTATION, NETWORK_PATTERN, WEBSOCKET_STREAMDataType: NUMERIC, TEXT, JSON, XML, BINARYPatternType: POLLING, EVENT_DRIVEN, BURST
-
Main Classes:
StreamDefinition: Complete stream metadata and lifecycleTimingPattern: Timing analysis (intervals, regularity, variance)StreamDataEvent: Individual stream data eventsExportConfig: Export configuration (Kafka, webhooks, etc.)StreamSubscription: Subscription management
-
Features:
- Full serialization (ToValue/FromValue)
- Parameter maps for network filtering
- Timing analysis structures
- Lifecycle tracking (first_seen, last_seen, event_count)
3. DOM Stream Tracker (dom_stream_tracker.{h,cc}, dom_mutation_tracker.js)
JavaScript Component (~330 lines):
MutationObservermonitors all DOM changes- Tracks up to 500 elements simultaneously
- Detects patterns after 3+ updates to same element
- Statistical analysis:
- Average update interval
- Standard deviation
- Coefficient of variation (regularity detection)
- Data type classification: NUMERIC, JSON, TEXT
- Throttled processing (100ms) for performance
- Automatic cleanup of inactive trackers (5 min timeout)
- Exposes API for manual scanning
C++ Component (~400 lines):
- Injects JavaScript into web pages
- Receives detected streams via postMessage
- Converts JavaScript data to C++ structures
- Pattern classification (POLLING, EVENT_DRIVEN, BURST)
- Callback-based stream notifications
- WebContentsObserver integration
- Automatic re-injection on navigation
Key Features:
- ✅ Detects elements updating at regular intervals (e.g., stock prices)
- ✅ Identifies data type (numeric, JSON, text)
- ✅ Calculates timing patterns and regularity
- ✅ Filters noise (only reports significant patterns)
- ✅ Performance optimized (throttling, cleanup)
- ✅ Full integration with Chromium content layer
Next Steps:
-
Create MutationObserver JavaScript (
dom_mutation_tracker.js)// Inject into every page // Track DOM changes with MutationObserver // Detect patterns (same element changing regularly) // Send detected streams via postMessage to C++
-
Implement DOMStreamTracker (
dom_stream_tracker.{h,cc})class DOMStreamTracker : public content::WebContentsObserver { // Inject JavaScript into page // Receive detected streams from JavaScript // Perform timing analysis // Classify data types // Notify stream registry };
-
Create BUILD.gn
- Add new streaming module to build system
- Link with base, content, components
Files to Create:
network_stream_analyzer.{h,cc}
Features:
- Group network requests by URL pattern
- Normalize URLs (
/api/user/123→/api/user/:id) - Extract URL parameters and POST body parameters
- Detect timing patterns (polling intervals)
- Create parameterized stream definitions
Files to Create:
stream_registry.{h,cc}stream_pattern_analyzer.{h,cc}stream_subscription.{h,cc}
Features:
- Central registry of all active streams
- Pattern matching and filtering
- Subscription management
- Circular buffer for stream data
- Database persistence
Files to Modify:
chrome/browser/ui/webui/side_panel/datasipper/datasipper.mojom
New Interfaces:
struct DataStream {
string stream_id;
string label;
StreamType type;
string source_pattern;
double avg_interval_ms;
map<string, string> parameters;
bool is_active;
bool is_subscribed;
};
struct StreamDataEvent {
string stream_id;
int64 timestamp_ms;
string data;
map<string, string> metadata;
};
interface DataSipperObserver {
OnStreamDetected(DataStream stream);
OnStreamDataUpdate(StreamDataEvent event);
OnStreamEnded(string stream_id);
};
interface DataSipperPageHandler {
GetActiveStreams() => (array<DataStream> streams);
GetStreamData(string stream_id, int64 limit) => (array<StreamDataEvent> events);
SubscribeToStream(string stream_id, ExportConfig config) => (bool success);
CreateParameterFilter(string stream_id, map<string, string> params) => (bool success);
RescanPageForStreams() => (int32 streams_found);
};
Files to Create:
chrome/browser/resources/side_panel/datasipper/streams.htmlchrome/browser/resources/side_panel/datasipper/streams.tschrome/browser/resources/side_panel/datasipper/streams.css
Features:
- Streams tab in DataSipper sidebar
- Stream list (grouped by type: DOM, Network, WebSocket)
- Parameter filter dialog for network streams
- Subscription controls
- Real-time data preview
Files to Modify:
components/datasipper/datasipper_database.{h,cc}
New Tables:
CREATE TABLE data_streams (
stream_id TEXT PRIMARY KEY,
type INTEGER,
source_pattern TEXT,
label TEXT,
avg_interval_ms REAL,
parameters_json TEXT,
first_seen INTEGER,
last_seen INTEGER,
event_count INTEGER,
is_active BOOLEAN
);
CREATE TABLE stream_events (
event_id INTEGER PRIMARY KEY,
stream_id TEXT,
timestamp_ms INTEGER,
data TEXT,
metadata_json TEXT
);
CREATE TABLE stream_subscriptions (
subscription_id TEXT PRIMARY KEY,
stream_id TEXT,
export_type INTEGER,
config_json TEXT,
subscribed_at INTEGER,
events_processed INTEGER
);Integration Points:
- Hook DOMStreamTracker into PageDataDetector
- Hook NetworkStreamAnalyzer into DataSipperNetworkBridge
- Connect Stream Registry to DataSipperService
- Wire up Mojo interfaces to page handlers
- Test end-to-end flow
Auto-Detection:
- User visits finance.yahoo.com
- DOMStreamTracker detects
div.price[data-symbol="AAPL"]updating every 5 seconds - Stream created: "AAPL Stock Price"
- Shows in UI with timing pattern and current value
- User subscribes to stream → data exported to webhook/Kafka
Auto-Detection:
- Page makes requests to
/api/weather?location=USA&units=imperialevery 30s - NetworkStreamAnalyzer detects pattern
- Stream created: "Weather API"
- UI shows parameter variants: [USA, UK, CA] × [imperial, metric]
- User creates filter: location=USA only
- New filtered stream: "Weather USA Only"
- Subscribe to export only USA weather data
Auto-Detection:
- ESPN page has WebSocket connection
- Messages contain score updates every few seconds
- WebSocketStreamDetector identifies pattern
- Stream created: "Live Game Scores"
- User subscribes to stream real-time scores to external dashboard
┌─────────────────────────────────────────────────────────────┐
│ Renderer Process │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────┐ │
│ │ DOM Mutation Tracker (JavaScript) │ │
│ │ - MutationObserver │ │
│ │ - Pattern Detection │ │
│ │ - Timing Analysis │ │
│ └───────────────┬──────────────────────┘ │
│ │ postMessage │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ DOMStreamTracker (C++) │ │
│ │ - Receive JS notifications │ │
│ │ - Classify streams │ │
│ └───────────────┬──────────────────────┘ │
└──────────────────┼──────────────────────────────────────────┘
│ Mojo IPC
┌──────────────────┼──────────────────────────────────────────┐
│ ▼ Browser Process │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────┐ │
│ │ NetworkStreamAnalyzer │ │
│ │ - Receive from NetworkObserver │ │
│ │ - Group by URL pattern │ │
│ │ - Extract parameters │ │
│ └───────────────┬──────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ Stream Registry │ │
│ │ - All active streams │ │
│ │ - Pattern matching │ │
│ │ - Subscriptions │ │
│ │ - Circular buffer │ │
│ └───────────────┬──────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ DataSipperService │ │
│ │ - Coordinate all streams │ │
│ │ - Database persistence │ │
│ └───────────────┬──────────────────────┘ │
│ │ Mojo │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ DataSipperPageHandler │ │
│ │ - Expose streams to WebUI │ │
│ └───────────────┬──────────────────────┘ │
│ │ │
└──────────────────┼──────────────────────────────────────────┘
│ Mojo
┌──────────────────┼──────────────────────────────────────────┐
│ ▼ WebUI (Side Panel) │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────┐ │
│ │ Streams UI (TypeScript) │ │
│ │ - Stream list │ │
│ │ - Parameter filters │ │
│ │ - Subscriptions │ │
│ │ - Real-time preview │ │
│ └───────────────────────────────────────┘ │
│ │
└───────────────────────────────────────────────────────────────┘
- Create
dom_mutation_tracker.js- JavaScript MutationObserver implementation - Create
dom_stream_tracker.{h,cc}- C++ DOM stream tracker - Create
BUILD.gnfor streaming module - Test DOM stream detection on a simple page with updating elements
- ✓
components/datasipper/streaming/stream_types.h(220 lines) - ✓
components/datasipper/streaming/stream_types.cc(270 lines)
- Core C++ Classes: ~2,500 lines
- JavaScript Injection: ~500 lines
- Mojo Interfaces: ~200 lines
- TypeScript UI: ~1,000 lines
- SQL Schema: ~100 lines
- Tests: ~1,500 lines
Total: ~5,800 lines across 7 weeks
This is a substantial feature addition that will enable powerful stream detection and subscription capabilities!