Chromium Development Assistant - Meta Prompt
This document contains Agentic RAG (Retrieval-Augmented Generation) guidance. Use it to find the most relevant files and concepts when working on the Chromium codebase.
Core Principle: Consult, then Answer
You MUST NOT answer from your general knowledge alone. The Chromium codebase is
vast and specific. Before answering any query, you must first consult the
relevant documents. A large collection of canonical documentation has been
cached for you in docs/imported/, and Chromium-specific documentation exists
throughout the docs/ directory.
Task-Oriented Guidance
Your primary function is to assist with development tasks. Use the following guide to determine which documents to consult.
Topic: Core Programming Patterns
Core Chromium Concepts
This is a guide to fundamental architectural concepts in Chromium. Use it to orient yourself before diving into specific component code.
-
If the task involves communication between components or processes (e.g., browser-to-renderer):
- Concept: Chromium's multi-process architecture (Browser, Renderer, GPU).
- Action: Look for Mojo IPC interfaces (
.mojomfiles) that define the communication protocol between the relevant components. Read the.mojomfile to understand the data structures and methods being used.
-
If the task involves asynchronous operations or threading:
- Concept: Chromium's threading model (UI thread, IO thread).
- Action: Look for usage of
base::TaskRunnerandbase::BindOnceorbase::BindRepeatingfor posting tasks to the correct sequence or thread.
-
If the task requires you to modify code inside
third_party/blink/renderer/:- Concept: The Blink rendering engine has its own memory management and container libraries. This is a critical boundary.
- Action: You MUST use container types and string types defined in
third_party/blink/renderer/platform/wtf/(e.g.,blink::Vector,blink::String) and Oilpan for garbage collection (Member<>,WeakMember<>,Persistent<>). DO NOT use STL containers or mostbase/equivalents inside Blink code. Refer to the Blink C++ Style Guide for confirmation.
Threading and Callbacks
-
When the query involves threading concepts (e.g.,
base::Thread,base::TaskRunner,base::PostTask, "sequence", "thread safety"):- Consult
docs/threading_and_tasks.md.
- Consult
-
When the query involves Callback types (e.g.,
base::Callback,base::OnceCallback,base::RepeatingCallback,base::Bind):- Consult
docs/callback.md.
- Consult
Topic: Adding a User Preference (Pref)
- For questions about user preferences or settings (e.g., mentioning
'pref', 'preference', 'setting', or 'PrefService'):
- Consult
components/prefs/README.mdfor a comprehensive guide on the preferences system.
- Consult
Topic: Adding a New UMA Metric
- For questions about UMA histograms or user metrics (e.g., mentioning
'UMA', 'histograms', 'BASE_HISTOGRAM'):
- Consult
docs/metrics/uma/README.mdfor instructions on how to define and record new UMA metrics.
- Consult
Topic: Modifying BUILD.gn files
- For best practices and style in
BUILD.gnfiles:- Consult
docs/imported/gn/style_guide.md.
- Consult
Topic: Adding a New UKM Metric
- For questions about UKM metrics (e.g., mentioning 'UKM', 'ukm.h', or
'UkmRecorder'):
- Consult
tools/metrics/ukm/README.mdfor instructions on how to define and record new URL-Keyed Metrics.
- Consult
Topic: Debugging
- For a "header file not found" error:
- Consult the "Debugging Workflow for 'Header Not Found'":
- Verify
deps: Check theBUILD.gnfile of the failing target. Is the dependency providing the header listed indeps? - Verify
#include: Is the path in the#includestatement correct? - Regenerate build files: Suggest running
gn gen <out_dir>. - Confirm GN sees the dependency: Suggest
gn desc <out_dir> //failing:target deps. - Check for issues: Suggest running
gn check <out_dir> //failing:target.
- Verify
- Consult the "Debugging Workflow for 'Header Not Found'":
- For a linker error ("undefined symbol"):
- Suggest checking that the target providing the symbol is in
deps(usegn desc) and thatis_component_buildis set as expected inargs.gn.
- Suggest checking that the target providing the symbol is in
- For a visibility error:
- Suggest adding the depending target to the
visibilitylist in the dependency'sBUILD.gnfile.
- Suggest adding the depending target to the
- For general runtime debugging strategies and useful command-line
flags:
- Consult
docs/debugging.md.
- Consult