Is is still possible to update CommandLinePrefStore after command line parameters is parsed and after profile has been initialized in chrome_browser_main.cc?

19 views
Skip to first unread message

Hu Tie

unread,
Dec 15, 2014, 11:41:04 PM12/15/14
to chromi...@chromium.org
Hi, 
I am trying to do some experiment on perf settings. 
Had a question, can I apply some command line parameters after profile has been initialized? 

I added some code in chrome_browser_main.cc, but it looks those changes do not affect anything: 

  // Post-profile init ---------------------------------------------------------
  // Add a new switch: 
  CommandLine* command_line_current = CommandLine::ForCurrentProcess();
  command_line_current->AppendSwitch(
         switches::kNoProxyServer);

  // Update local_state: 
  local_state_->UpdateCommandLinePrefStore(
        new CommandLinePrefStore(command_line_current));

Just curious to know is it possible to change the system settings through command line parameters interfaces after system started up. Thank you!

Brett Wilson

unread,
Dec 16, 2014, 12:02:13 AM12/16/14
to tie...@gmail.com, Chromium-dev
I don't know why that's not working for you, but it's a very bad idea.
I believe there will be multiple threads at that point, so your code
will likely cause race conditions or corruption if another thread
reads it at the same time.

Brett
> --
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev

Hu Tie

unread,
Dec 16, 2014, 12:42:54 AM12/16/14
to Brett Wilson, Chromium-dev
Hi Brett, 
Thank you for your reply. It's still in post profile init procedure. Since I update local_state through it's interface UpdateCommandLinePrefStore() it should not cause any race conditions or corruptions cause those data structures must have been protected by mutexes already. 

I looked into the code a bit, it looks UpdateCommandLinePrefStore() just removed all existing observers, re-initializes a new command line pref store and re install all observers, so the observers does not feel the change of the value and did not push the flag changes up to the related modules. 

Brett Wilson

unread,
Dec 16, 2014, 1:40:53 AM12/16/14
to Hu Tie, Chromium-dev
I was actually concerned about how you modify the command line
structure. It looks like you're modifying the global singleton which
is used on different threads. And I'm pretty sure that's not
threadsafe.

I don't know anything about the PrefStore thing you're doing, sorry.
But I would recommend making a copy of the command line if you need to
modify it.

Brett
Reply all
Reply to author
Forward
0 new messages