Creating a Shared Memory Object Across Different Directories in Chromium Codebase

185 views
Skip to first unread message

Kartikeya Sehgal

unread,
Sep 17, 2024, 11:21:08 AM9/17/24
to Chromium-dev

Hi everyone,
I’m working on a project within the Chromium code base and have encountered a situation where I need to create a shared memory object (or shared variable) across different directories. The challenge is that these directories don’t seem to share any common files or include headers from each other.

  1. What’s the recommended approach for sharing variables or memory objects in such a case?
  2. Are there any design patterns or best practices within Chromium for inter-directory communication or data sharing?

I’ve come across some IPC mechanisms in Chromium, but I’m not sure if that’s the right direction, especially for simple shared variables. Any guidance or suggestions would be greatly appreciated!

Thanks in advance!


Joe Mason

unread,
Sep 17, 2024, 2:49:32 PM9/17/24
to kartikeya...@gmail.com, Chromium-dev
I'm not sure what you mean by a "shared memory object" here.

Do you need to share some data between different processes? (eg. the browser process and a renderer or utility process - see https://www.chromium.org/developers/design-documents/multi-process-architecture/ for details of the different process types.) That would need IPC.

The directory that your code is in doesn't really matter in that case, except that to keep the code organized, code that's restricted to run in the browser process is usually put in directories called ".../browser/..." and code that's restricted to run in a renderer is usually put in directories called ".../renderer/...". That's just a convention, though.

Or are you just to store data in a C++ variable, and access that variable from different source code files that happen to be in different directories? In that case, you need to find a directory that all our source files are allowed to include, and put accessors for your variable in a header in that directory. https://www.chromium.org/developers/how-tos/getting-around-the-chrome-source-code/ describes the directory structure.

Figuring out the correct lifetime of your data can be tricky. There are a few common patterns that I could point out, depending on what exactly you're trying to do. Can you give more details of the data you're sharing and the directories involved?

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/3c506471-fe1b-4f68-81e6-742d5eb386e1n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages