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

Side by Side Diff: chrome/renderer/render_thread.cc

Issue 1660: Move a bunch of code from the old to new TLS interface. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h> 5 #include <windows.h>
6 #include <algorithm> 6 #include <algorithm>
7 7
8 #include "chrome/renderer/render_thread.h" 8 #include "chrome/renderer/render_thread.h"
9 9
10 #include "base/lazy_instance.h"
10 #include "base/shared_memory.h" 11 #include "base/shared_memory.h"
12 #include "base/thread_local.h"
11 #include "chrome/common/ipc_logging.h" 13 #include "chrome/common/ipc_logging.h"
12 #include "chrome/common/notification_service.h" 14 #include "chrome/common/notification_service.h"
13 #include "chrome/plugin/plugin_channel.h" 15 #include "chrome/plugin/plugin_channel.h"
14 #include "chrome/renderer/net/render_dns_master.h" 16 #include "chrome/renderer/net/render_dns_master.h"
15 #include "chrome/renderer/render_process.h" 17 #include "chrome/renderer/render_process.h"
16 #include "chrome/renderer/render_view.h" 18 #include "chrome/renderer/render_view.h"
17 #include "chrome/renderer/visitedlink_slave.h" 19 #include "chrome/renderer/visitedlink_slave.h"
18 #include "webkit/glue/cache_manager.h" 20 #include "webkit/glue/cache_manager.h"
19 21
20 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; 22 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
21 23
22 // V8 needs a 1MB stack size. 24 // V8 needs a 1MB stack size.
23 static const size_t kStackSize = 1024 * 1024; 25 static const size_t kStackSize = 1024 * 1024;
24 26
25 // TODO(evanm): don't rely on static initialization. 27 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> >
26 // static 28 lazy_tls_ptr(base::LINKER_INITIALIZED);
27 TLSSlot RenderThread::tls_index_;
28 29
29 //----------------------------------------------------------------------------- 30 //-----------------------------------------------------------------------------
30 // Methods below are only called on the owner's thread: 31 // Methods below are only called on the owner's thread:
31 32
33 // static
34 RenderThread* RenderThread::current() {
35 return lazy_tls_ptr.Pointer()->Get();
36 }
37
32 RenderThread::RenderThread(const std::wstring& channel_name) 38 RenderThread::RenderThread(const std::wstring& channel_name)
33 : Thread("Chrome_RenderThread"), 39 : Thread("Chrome_RenderThread"),
34 channel_name_(channel_name), 40 channel_name_(channel_name),
35 owner_loop_(MessageLoop::current()), 41 owner_loop_(MessageLoop::current()),
36 visited_link_slave_(NULL), 42 visited_link_slave_(NULL),
37 render_dns_master_(NULL), 43 render_dns_master_(NULL),
38 in_send_(0) { 44 in_send_(0) {
39 DCHECK(owner_loop_); 45 DCHECK(owner_loop_);
40 base::Thread::Options options; 46 base::Thread::Options options;
41 options.stack_size = kStackSize; 47 options.stack_size = kStackSize;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 98
93 notification_service_.reset(new NotificationService); 99 notification_service_.reset(new NotificationService);
94 100
95 cache_stats_factory_.reset( 101 cache_stats_factory_.reset(
96 new ScopedRunnableMethodFactory<RenderThread>(this)); 102 new ScopedRunnableMethodFactory<RenderThread>(this));
97 103
98 channel_.reset(new IPC::SyncChannel(channel_name_, 104 channel_.reset(new IPC::SyncChannel(channel_name_,
99 IPC::Channel::MODE_CLIENT, this, NULL, owner_loop_, true, 105 IPC::Channel::MODE_CLIENT, this, NULL, owner_loop_, true,
100 RenderProcess::GetShutDownEvent())); 106 RenderProcess::GetShutDownEvent()));
101 107
102 tls_index_.Set(this); 108 lazy_tls_ptr.Pointer()->Set(this);
103 109
104 // The renderer thread should wind-up COM. 110 // The renderer thread should wind-up COM.
105 CoInitialize(0); 111 CoInitialize(0);
106 112
107 // TODO(darin): We should actually try to share this object between 113 // TODO(darin): We should actually try to share this object between
108 // RenderThread instances. 114 // RenderThread instances.
109 visited_link_slave_ = new VisitedLinkSlave(); 115 visited_link_slave_ = new VisitedLinkSlave();
110 116
111 render_dns_master_.reset(new RenderDnsMaster()); 117 render_dns_master_.reset(new RenderDnsMaster());
112 118
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // Rate limit informing the host of our cache stats. 208 // Rate limit informing the host of our cache stats.
203 if (!cache_stats_factory_->empty()) 209 if (!cache_stats_factory_->empty())
204 return; 210 return;
205 211
206 MessageLoop::current()->PostDelayedTask(FROM_HERE, 212 MessageLoop::current()->PostDelayedTask(FROM_HERE,
207 cache_stats_factory_->NewRunnableMethod( 213 cache_stats_factory_->NewRunnableMethod(
208 &RenderThread::InformHostOfCacheStats), 214 &RenderThread::InformHostOfCacheStats),
209 kCacheStatsDelayMS); 215 kCacheStatsDelayMS);
210 } 216 }
211 217
OLDNEW
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698