Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: content/child/child_thread_impl.cc

Issue 974933002: content: Refactor ChildThreadImpl::Options (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/gpu/gpu_child_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/child_thread_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return ChildThreadImpl::current(); 203 return ChildThreadImpl::current();
204 } 204 }
205 205
206 ChildThreadImpl::Options::Options() 206 ChildThreadImpl::Options::Options()
207 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 207 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
208 switches::kProcessChannelID)), 208 switches::kProcessChannelID)),
209 use_mojo_channel(false), 209 use_mojo_channel(false),
210 in_browser_process(false) { 210 in_browser_process(false) {
211 } 211 }
212 212
213 ChildThreadImpl::Options::Options(bool mojo)
214 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
215 switches::kProcessChannelID)),
216 use_mojo_channel(mojo),
217 in_browser_process(true) {
218 }
219
220 ChildThreadImpl::Options::Options(std::string name, bool mojo)
221 : channel_name(name), use_mojo_channel(mojo), in_browser_process(true) {
222 }
223
224 ChildThreadImpl::Options::~Options() { 213 ChildThreadImpl::Options::~Options() {
225 } 214 }
226 215
216 ChildThreadImpl::Options::Builder::Builder() {
217 }
218
219 ChildThreadImpl::Options::Builder&
220 ChildThreadImpl::Options::Builder::InBrowserProcess(bool in_browser_process) {
221 options_.in_browser_process = in_browser_process;
222 return *this;
223 }
224
225 ChildThreadImpl::Options::Builder&
226 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) {
227 options_.use_mojo_channel = use_mojo_channel;
228 return *this;
229 }
230
231 ChildThreadImpl::Options::Builder&
232 ChildThreadImpl::Options::Builder::WithChannelName(
233 const std::string& channel_name) {
234 options_.channel_name = channel_name;
235 return *this;
236 }
237
238 ChildThreadImpl::Options::Builder&
239 ChildThreadImpl::Options::Builder::AddStartupFilter(
240 IPC::MessageFilter* filter) {
241 options_.startup_filters.push_back(filter);
242 return *this;
243 }
244
245 ChildThreadImpl::Options ChildThreadImpl::Options::Builder::Build() {
246 return options_;
247 }
248
227 ChildThreadImpl::ChildThreadMessageRouter::ChildThreadMessageRouter( 249 ChildThreadImpl::ChildThreadMessageRouter::ChildThreadMessageRouter(
228 IPC::Sender* sender) 250 IPC::Sender* sender)
229 : sender_(sender) {} 251 : sender_(sender) {}
230 252
231 bool ChildThreadImpl::ChildThreadMessageRouter::Send(IPC::Message* msg) { 253 bool ChildThreadImpl::ChildThreadMessageRouter::Send(IPC::Message* msg) {
232 return sender_->Send(msg); 254 return sender_->Send(msg);
233 } 255 }
234 256
235 ChildThreadImpl::ChildThreadImpl() 257 ChildThreadImpl::ChildThreadImpl()
236 : router_(this), 258 : router_(this),
237 in_browser_process_(false), 259 in_browser_process_(false),
238 channel_connected_factory_(this) { 260 channel_connected_factory_(this) {
239 Init(Options()); 261 Init(Options::Builder().Build());
240 } 262 }
241 263
242 ChildThreadImpl::ChildThreadImpl(const Options& options) 264 ChildThreadImpl::ChildThreadImpl(const Options& options)
243 : router_(this), 265 : router_(this),
244 in_browser_process_(options.in_browser_process), 266 in_browser_process_(options.in_browser_process),
245 channel_connected_factory_(this) { 267 channel_connected_factory_(this) {
246 Init(options); 268 Init(options);
247 } 269 }
248 270
249 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) { 271 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 // doesn't cause such issues. TODO(gab): Remove this once the experiment is 685 // doesn't cause such issues. TODO(gab): Remove this once the experiment is
664 // over (http://crbug.com/458594). 686 // over (http://crbug.com/458594).
665 base::FieldTrial* trial = 687 base::FieldTrial* trial =
666 base::FieldTrialList::Find("BackgroundRendererProcesses"); 688 base::FieldTrialList::Find("BackgroundRendererProcesses");
667 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer") 689 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer")
668 base::Process::Current().SetProcessBackgrounded(background); 690 base::Process::Current().SetProcessBackgrounded(background);
669 #endif // OS_WIN 691 #endif // OS_WIN
670 } 692 }
671 693
672 } // namespace content 694 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/gpu/gpu_child_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698