summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 03:25:15 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 03:25:15 +0000
commit176aa48371da91eb98d675d87b4e70c7b26d696f (patch)
tree4c972de6ecd5a54650ab1dc7d421187f5d25834f /chrome/renderer
parent9a3f0ac2899139ace97e399015259d028b4d5704 (diff)
downloadchromium_src-176aa48371da91eb98d675d87b4e70c7b26d696f.zip
chromium_src-176aa48371da91eb98d675d87b4e70c7b26d696f.tar.gz
chromium_src-176aa48371da91eb98d675d87b4e70c7b26d696f.tar.bz2
Add Terminate() to the Process object, have RenderProcessHost use this to avoid some more Windows specific code.
Move Process and SharedMemory into the base namespace (most changes). Review URL: http://codereview.chromium.org/10895 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/greasemonkey_slave.cc6
-rw-r--r--chrome/renderer/greasemonkey_slave.h10
-rw-r--r--chrome/renderer/greasemonkey_slave_unittest.cc3
-rw-r--r--chrome/renderer/render_process.cc18
-rw-r--r--chrome/renderer/render_process.h12
-rw-r--r--chrome/renderer/render_thread.cc7
-rw-r--r--chrome/renderer/render_thread.h4
-rw-r--r--chrome/renderer/render_view.cc2
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--chrome/renderer/render_widget.cc3
-rw-r--r--chrome/renderer/render_widget.h6
-rw-r--r--chrome/renderer/renderer_glue.cc4
-rw-r--r--chrome/renderer/visitedlink_slave.cc4
-rw-r--r--chrome/renderer/visitedlink_slave.h12
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc6
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.h8
16 files changed, 53 insertions, 55 deletions
diff --git a/chrome/renderer/greasemonkey_slave.cc b/chrome/renderer/greasemonkey_slave.cc
index 5a4072a..f2de9fb 100644
--- a/chrome/renderer/greasemonkey_slave.cc
+++ b/chrome/renderer/greasemonkey_slave.cc
@@ -113,11 +113,11 @@ std::string GreasemonkeyScript::EscapeGlob(const std::string& input_pattern) {
GreasemonkeySlave::GreasemonkeySlave() : shared_memory_(NULL) {
}
-bool GreasemonkeySlave::UpdateScripts(SharedMemoryHandle shared_memory) {
+bool GreasemonkeySlave::UpdateScripts(base::SharedMemoryHandle shared_memory) {
scripts_.clear();
- // Create the shared memory object.
- shared_memory_.reset(new SharedMemory(shared_memory, true)); // read-only
+ // Create the shared memory object (read only).
+ shared_memory_.reset(new base::SharedMemory(shared_memory, true));
if (!shared_memory_.get())
return false;
diff --git a/chrome/renderer/greasemonkey_slave.h b/chrome/renderer/greasemonkey_slave.h
index 5be3697..5f80f8b 100644
--- a/chrome/renderer/greasemonkey_slave.h
+++ b/chrome/renderer/greasemonkey_slave.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_RENDERER_GREASEMONKEY_SLAVE_H__
-#define CHROME_RENDERER_GREASEMONKEY_SLAVE_H__
+#ifndef CHROME_RENDERER_GREASEMONKEY_SLAVE_H_
+#define CHROME_RENDERER_GREASEMONKEY_SLAVE_H_
#include "base/scoped_ptr.h"
#include "base/shared_memory.h"
@@ -75,7 +75,7 @@ class GreasemonkeySlave {
GreasemonkeySlave();
// Update the parsed scripts from shared memory.
- bool UpdateScripts(SharedMemoryHandle shared_memory);
+ bool UpdateScripts(base::SharedMemoryHandle shared_memory);
// Inject the appropriate scripts into a frame based on its URL.
// TODO(aa): Extract a GreasemonkeyFrame interface out of this to improve
@@ -84,7 +84,7 @@ class GreasemonkeySlave {
private:
// Shared memory containing raw script data.
- scoped_ptr<SharedMemory> shared_memory_;
+ scoped_ptr<base::SharedMemory> shared_memory_;
// Parsed script data.
std::vector<GreasemonkeyScript> scripts_;
@@ -92,4 +92,4 @@ class GreasemonkeySlave {
DISALLOW_COPY_AND_ASSIGN(GreasemonkeySlave);
};
-#endif // CHROME_RENDERER_GREASEMONKEY_SLAVE_H__
+#endif // CHROME_RENDERER_GREASEMONKEY_SLAVE_H_
diff --git a/chrome/renderer/greasemonkey_slave_unittest.cc b/chrome/renderer/greasemonkey_slave_unittest.cc
index 06c48c2..bedbfbf 100644
--- a/chrome/renderer/greasemonkey_slave_unittest.cc
+++ b/chrome/renderer/greasemonkey_slave_unittest.cc
@@ -7,9 +7,6 @@
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
-class GreasemonkeySlaveTest : public testing::Test {
-};
-
TEST(GreasemonkeySlaveTest, EscapeGlob) {
EXPECT_EQ("", GreasemonkeyScript::EscapeGlob(""));
EXPECT_EQ("*", GreasemonkeyScript::EscapeGlob("*"));
diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc
index 44a8055..b2b4606 100644
--- a/chrome/renderer/render_process.cc
+++ b/chrome/renderer/render_process.cc
@@ -108,10 +108,10 @@ bool RenderProcess::ShouldLoadPluginsInProcess() {
}
// static
-SharedMemory* RenderProcess::AllocSharedMemory(size_t size) {
+base::SharedMemory* RenderProcess::AllocSharedMemory(size_t size) {
self()->clearer_factory_.RevokeAll();
- SharedMemory* mem = self()->GetSharedMemFromCache(size);
+ base::SharedMemory* mem = self()->GetSharedMemFromCache(size);
if (mem)
return mem;
@@ -122,7 +122,7 @@ SharedMemory* RenderProcess::AllocSharedMemory(size_t size) {
size = size / info.dwAllocationGranularity + 1;
size = size * info.dwAllocationGranularity;
- mem = new SharedMemory();
+ mem = new base::SharedMemory();
if (!mem)
return NULL;
if (!mem->Create(L"", false, true, size)) {
@@ -134,7 +134,7 @@ SharedMemory* RenderProcess::AllocSharedMemory(size_t size) {
}
// static
-void RenderProcess::FreeSharedMemory(SharedMemory* mem) {
+void RenderProcess::FreeSharedMemory(base::SharedMemory* mem) {
if (self()->PutSharedMemInCache(mem)) {
self()->ScheduleCacheClearer();
return;
@@ -143,14 +143,14 @@ void RenderProcess::FreeSharedMemory(SharedMemory* mem) {
}
// static
-void RenderProcess::DeleteSharedMem(SharedMemory* mem) {
+void RenderProcess::DeleteSharedMem(base::SharedMemory* mem) {
delete mem;
}
-SharedMemory* RenderProcess::GetSharedMemFromCache(size_t size) {
+base::SharedMemory* RenderProcess::GetSharedMemFromCache(size_t size) {
// look for a cached object that is suitable for the requested size.
for (int i = 0; i < arraysize(shared_mem_cache_); ++i) {
- SharedMemory* mem = shared_mem_cache_[i];
+ base::SharedMemory* mem = shared_mem_cache_[i];
if (mem && mem->max_size() >= size) {
shared_mem_cache_[i] = NULL;
return mem;
@@ -159,7 +159,7 @@ SharedMemory* RenderProcess::GetSharedMemFromCache(size_t size) {
return NULL;
}
-bool RenderProcess::PutSharedMemInCache(SharedMemory* mem) {
+bool RenderProcess::PutSharedMemInCache(base::SharedMemory* mem) {
// simple algorithm:
// - look for an empty slot to store mem, or
// - if full, then replace any existing cache entry that is smaller than the
@@ -171,7 +171,7 @@ bool RenderProcess::PutSharedMemInCache(SharedMemory* mem) {
}
}
for (int i = 0; i < arraysize(shared_mem_cache_); ++i) {
- SharedMemory* cached_mem = shared_mem_cache_[i];
+ base::SharedMemory* cached_mem = shared_mem_cache_[i];
if (cached_mem->max_size() < mem->max_size()) {
shared_mem_cache_[i] = mem;
DeleteSharedMem(cached_mem);
diff --git a/chrome/renderer/render_process.h b/chrome/renderer/render_process.h
index 8fcb186..bdba635 100644
--- a/chrome/renderer/render_process.h
+++ b/chrome/renderer/render_process.h
@@ -30,14 +30,14 @@ class RenderProcess : public ChildProcess {
// reported in the resulting SharedMemory object will be greater than or
// equal to the requested size. This method returns NULL if unable to
// allocate memory for some reason.
- static SharedMemory* AllocSharedMemory(size_t size);
+ static base::SharedMemory* AllocSharedMemory(size_t size);
// Frees shared memory allocated by AllocSharedMemory. You should only use
// this function to free the SharedMemory object.
- static void FreeSharedMemory(SharedMemory* mem);
+ static void FreeSharedMemory(base::SharedMemory* mem);
// Deletes the shared memory allocated by AllocSharedMemory.
- static void DeleteSharedMem(SharedMemory* mem);
+ static void DeleteSharedMem(base::SharedMemory* mem);
private:
friend class ChildProcessFactory<RenderProcess>;
@@ -54,12 +54,12 @@ class RenderProcess : public ChildProcess {
// Look in the shared memory cache for a suitable object to reuse. Returns
// NULL if there is none.
- SharedMemory* GetSharedMemFromCache(size_t size);
+ base::SharedMemory* GetSharedMemFromCache(size_t size);
// Maybe put the given shared memory into the shared memory cache. Returns
// true if the SharedMemory object was stored in the cache; otherwise, false
// is returned.
- bool PutSharedMemInCache(SharedMemory* mem);
+ bool PutSharedMemInCache(base::SharedMemory* mem);
void ClearSharedMemCache();
@@ -76,7 +76,7 @@ class RenderProcess : public ChildProcess {
// A very simplistic and small cache. If an entry in this array is non-null,
// then it points to a SharedMemory object that is available for reuse.
- SharedMemory* shared_mem_cache_[2];
+ base::SharedMemory* shared_mem_cache_[2];
// This factory is used to lazily invoke ClearSharedMemCache.
ScopedRunnableMethodFactory<RenderProcess> clearer_factory_;
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index fd262de..60ac402 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -148,14 +148,15 @@ void RenderThread::CleanUp() {
CoUninitialize();
}
-void RenderThread::OnUpdateVisitedLinks(SharedMemoryHandle table) {
+void RenderThread::OnUpdateVisitedLinks(base::SharedMemoryHandle table) {
DCHECK(table) << "Bad table handle";
visited_link_slave_->Init(table);
}
-void RenderThread::OnUpdateGreasemonkeyScripts(SharedMemoryHandle scripts) {
+void RenderThread::OnUpdateGreasemonkeyScripts(
+ base::SharedMemoryHandle scripts) {
DCHECK(scripts) << "Bad scripts handle";
- greasemonkey_slave_->UpdateScripts(scripts);
+ greasemonkey_slave_->UpdateScripts(scripts);
}
void RenderThread::OnMessageReceived(const IPC::Message& msg) {
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index 38fd144..6de92324 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -93,8 +93,8 @@ class RenderThread : public IPC::Channel::Listener,
virtual void CleanUp();
private:
- void OnUpdateVisitedLinks(SharedMemoryHandle table);
- void OnUpdateGreasemonkeyScripts(SharedMemoryHandle table);
+ void OnUpdateVisitedLinks(base::SharedMemoryHandle table);
+ void OnUpdateGreasemonkeyScripts(base::SharedMemoryHandle table);
void OnPluginMessage(const std::wstring& dll_path,
const std::vector<uint8>& data);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 30cd633..7e812a45 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -581,7 +581,7 @@ void RenderView::PrintPage(const ViewMsg_PrintPage_Params& params,
page_params.page_number = params.page_number;
page_params.document_cookie = params.params.document_cookie;
page_params.actual_shrink = shrink;
- SharedMemory shared_buf;
+ base::SharedMemory shared_buf;
// http://msdn2.microsoft.com/en-us/library/ms535522.aspx
// Windows 2000/XP: When a page in a spooled file exceeds approximately 350
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index a78df39..7ee0f8f 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -38,7 +38,6 @@
class DebugMessageHandler;
class GURL;
-class SharedMemory;
class SkBitmap;
struct ThumbnailScore;
class WebError;
@@ -48,7 +47,7 @@ class WebPluginDelegateProxy;
enum WebRequestCachePolicy;
namespace webkit_glue {
- struct FileUploadData;
+struct FileUploadData;
}
// We need to prevent a page from trying to create infinite popups. It is not
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index ab1a270..7f0f7ca 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -354,7 +354,8 @@ void RenderWidget::ClearFocus() {
webwidget_->SetFocus(false);
}
-void RenderWidget::PaintRect(const gfx::Rect& rect, SharedMemory* paint_buf) {
+void RenderWidget::PaintRect(const gfx::Rect& rect,
+ base::SharedMemory* paint_buf) {
gfx::PlatformCanvasWin canvas(rect.width(), rect.height(), true,
paint_buf->handle());
// Bring the canvas into the coordinate system of the paint rect
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index f597dff..f69d77e 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -101,7 +101,7 @@ class RenderWidget : public IPC::Channel::Listener,
// Paints the given rectangular region of the WebWidget into paint_buf (a
// shared memory segment returned by AllocPaintBuf). The caller must ensure
// that the given rect fits within the bounds of the WebWidget.
- void PaintRect(const gfx::Rect& rect, SharedMemory* paint_buf);
+ void PaintRect(const gfx::Rect& rect, base::SharedMemory* paint_buf);
// Get the size of the paint buffer for the given rectangle, rounding up to
// the allocation granularity of the system.
@@ -204,8 +204,8 @@ class RenderWidget : public IPC::Channel::Listener,
// Shared memory handles that are currently in use to transfer an image to
// the browser.
- SharedMemory* current_paint_buf_;
- SharedMemory* current_scroll_buf_;
+ base::SharedMemory* current_paint_buf_;
+ base::SharedMemory* current_scroll_buf_;
// The smallest bounding rectangle that needs to be re-painted. This is non-
// empty if a paint event is pending.
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 1cc689f..0d958cf 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -95,10 +95,10 @@ void ScopedClipboardWriterGlue::WriteBitmap(const SkBitmap& bitmap) {
shared_buf_->Unmap();
Clipboard::ObjectMapParam param1, param2;
- SharedMemoryHandle smh = shared_buf_->handle();
+ base::SharedMemoryHandle smh = shared_buf_->handle();
const char* shared_handle = reinterpret_cast<const char*>(&smh);
- for (size_t i = 0; i < sizeof SharedMemoryHandle; i++)
+ for (size_t i = 0; i < sizeof base::SharedMemoryHandle; i++)
param1.push_back(shared_handle[i]);
const char* size_data = reinterpret_cast<const char*>(&size);
diff --git a/chrome/renderer/visitedlink_slave.cc b/chrome/renderer/visitedlink_slave.cc
index 3c928f9..1e6092b 100644
--- a/chrome/renderer/visitedlink_slave.cc
+++ b/chrome/renderer/visitedlink_slave.cc
@@ -15,14 +15,14 @@ VisitedLinkSlave::~VisitedLinkSlave() {
// This function's job is to initialize the table with the given
// shared memory handle. This memory is mappend into the process.
-bool VisitedLinkSlave::Init(SharedMemoryHandle shared_memory) {
+bool VisitedLinkSlave::Init(base::SharedMemoryHandle shared_memory) {
// since this function may be called again to change the table, we may need
// to free old objects
FreeTable();
DCHECK(shared_memory_ == NULL && hash_table_ == NULL);
// create the shared memory object
- shared_memory_ = new SharedMemory(shared_memory, true);
+ shared_memory_ = new base::SharedMemory(shared_memory, true);
if (!shared_memory_)
return false;
diff --git a/chrome/renderer/visitedlink_slave.h b/chrome/renderer/visitedlink_slave.h
index ff5ff64..39752fd0 100644
--- a/chrome/renderer/visitedlink_slave.h
+++ b/chrome/renderer/visitedlink_slave.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_WIN_RENDERER_VISITEDLINK_SLAVE_H__
-#define CHROME_WIN_RENDERER_VISITEDLINK_SLAVE_H__
+#ifndef CHROME_RENDERER_VISITEDLINK_SLAVE_H_
+#define CHROME_RENDERER_VISITEDLINK_SLAVE_H_
#include "base/shared_memory.h"
#include "chrome/common/visitedlink_common.h"
@@ -20,15 +20,15 @@ class VisitedLinkSlave : public VisitedLinkCommon
// It can also be called again at any time to update the table that we're
// using. The handle should be the handle generated by the VisitedLinkMaster.
// Returns true on success.
- bool Init(SharedMemoryHandle shared_memory);
+ bool Init(base::SharedMemoryHandle shared_memory);
private:
void FreeTable();
// shared memory consists of a SharedHeader followed by the table
- SharedMemory* shared_memory_;
+ base::SharedMemory* shared_memory_;
- DISALLOW_EVIL_CONSTRUCTORS(VisitedLinkSlave);
+ DISALLOW_COPY_AND_ASSIGN(VisitedLinkSlave);
};
-#endif // WIN_RENDERER_VISITEDLINK_SLAVE_H__
+#endif // CHROME_RENDERER_VISITEDLINK_SLAVE_H_
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index efceffb..13b06a3 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -397,10 +397,10 @@ void WebPluginDelegateProxy::ResetWindowlessBitmaps() {
}
bool WebPluginDelegateProxy::CreateBitmap(
- scoped_ptr<SharedMemory>* memory,
+ scoped_ptr<base::SharedMemory>* memory,
scoped_ptr<gfx::PlatformCanvasWin>* canvas) {
size_t size = GetPaintBufSize(plugin_rect_);
- scoped_ptr<SharedMemory> new_shared_memory(new SharedMemory());
+ scoped_ptr<base::SharedMemory> new_shared_memory(new base::SharedMemory());
if (!new_shared_memory->Create(L"", false, true, size))
return false;
@@ -515,7 +515,7 @@ void WebPluginDelegateProxy::Print(HDC hdc) {
PluginMsg_PrintResponse_Params params = { 0 };
Send(new PluginMsg_Print(instance_id_, &params));
- SharedMemory memory(params.shared_memory, true);
+ base::SharedMemory memory(params.shared_memory, true);
if (!memory.Map(params.size)) {
NOTREACHED();
return;
diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h
index b401baa..a11d083 100644
--- a/chrome/renderer/webplugin_delegate_proxy.h
+++ b/chrome/renderer/webplugin_delegate_proxy.h
@@ -144,7 +144,7 @@ class WebPluginDelegateProxy : public WebPluginDelegate,
void ResetWindowlessBitmaps();
// Creates a shared memory section and canvas.
- bool CreateBitmap(scoped_ptr<SharedMemory>* memory,
+ bool CreateBitmap(scoped_ptr<base::SharedMemory>* memory,
scoped_ptr<gfx::PlatformCanvasWin>* canvas);
RenderView* render_view_;
@@ -182,11 +182,11 @@ class WebPluginDelegateProxy : public WebPluginDelegate,
// store when we get an invalidate from it. The background bitmap is used
// for transparent plugins, as they need the backgroud data during painting.
bool transparent_;
- scoped_ptr<SharedMemory> backing_store_;
+ scoped_ptr<base::SharedMemory> backing_store_;
scoped_ptr<gfx::PlatformCanvasWin> backing_store_canvas_;
- scoped_ptr<SharedMemory> transport_store_;
+ scoped_ptr<base::SharedMemory> transport_store_;
scoped_ptr<gfx::PlatformCanvasWin> transport_store_canvas_;
- scoped_ptr<SharedMemory> background_store_;
+ scoped_ptr<base::SharedMemory> background_store_;
scoped_ptr<gfx::PlatformCanvasWin> background_store_canvas_;
DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateProxy);