summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_process.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-06 02:53:28 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-06 02:53:28 +0000
commit00c39612a3ec84f8d1f26975f3936bffc183591a (patch)
tree92474ab446150f025becaefd3868e02f72bea1fc /chrome/renderer/render_process.h
parent23dd7db09af6da5643e10d839b23d484a5b41eab (diff)
downloadchromium_src-00c39612a3ec84f8d1f26975f3936bffc183591a.zip
chromium_src-00c39612a3ec84f8d1f26975f3936bffc183591a.tar.gz
chromium_src-00c39612a3ec84f8d1f26975f3936bffc183591a.tar.bz2
Make the pepper 2D flush callback actually function as advertised. It will now
get called asynchronously when the bits are actually copied to the screen, rather than synchronously from inside the paint function. This makes it useful for plugins to use the callback for rate limiting. This also adds a lot of infrastructure for running tests on pepper devices, and includes a unit test for the new flush behavior. I made the existing RenderProcess object an abstract interface and made the existing MockProcess (renamed to be more clear) implement that. This avoids a static cast that would actually crash during a unit test because some code was hardcoded to expect a RenderProcess object. This fixes base's IDMap iterator which has apparently never been used for an IDMap with ownership semantics. TEST=Unit test included BUG=none Original review URL: http://codereview.chromium.org/661124 Review URL: http://codereview.chromium.org/664001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_process.h')
-rw-r--r--chrome/renderer/render_process.h94
1 files changed, 27 insertions, 67 deletions
diff --git a/chrome/renderer/render_process.h b/chrome/renderer/render_process.h
index 4c682dc..ed002cf 100644
--- a/chrome/renderer/render_process.h
+++ b/chrome/renderer/render_process.h
@@ -1,29 +1,34 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_RENDERER_RENDER_PROCESS_H__
-#define CHROME_RENDERER_RENDER_PROCESS_H__
+#ifndef CHROME_RENDERER_RENDER_PROCESS_H_
+#define CHROME_RENDERER_RENDER_PROCESS_H_
-#include "base/timer.h"
#include "chrome/common/child_process.h"
-#include "chrome/renderer/render_thread.h"
-#include "native_client/src/shared/imc/nacl_imc.h"
#include "skia/ext/platform_canvas.h"
+class TransportDIB;
+
namespace gfx {
class Rect;
}
-class TransportDIB;
+namespace skia {
+class PlatformCanvas;
+}
-// Represents the renderer end of the browser<->renderer connection. The
-// opposite end is the RenderProcessHost. This is a singleton object for
-// each renderer.
+// A abstract interface representing the renderer end of the browser<->renderer
+// connection. The opposite end is the RenderProcessHost. This is a singleton
+// object for each renderer.
+//
+// RenderProcessImpl implements this interface for the regular browser.
+// MockRenderProcess implements this interface for certain tests, especially
+// ones derived from RenderViewTest.
class RenderProcess : public ChildProcess {
public:
- RenderProcess();
- ~RenderProcess();
+ RenderProcess() {}
+ virtual ~RenderProcess() {}
// Get a canvas suitable for drawing and transporting to the browser
// memory: (output) the transport DIB memory
@@ -32,72 +37,27 @@ class RenderProcess : public ChildProcess {
//
// When no longer needed, you should pass the TransportDIB to
// ReleaseTransportDIB so that it can be recycled.
- skia::PlatformCanvas* GetDrawingCanvas(
- TransportDIB** memory, const gfx::Rect& rect);
+ virtual skia::PlatformCanvas* GetDrawingCanvas(TransportDIB** memory,
+ const gfx::Rect& rect) = 0;
// Frees shared memory allocated by AllocSharedMemory. You should only use
// this function to free the SharedMemory object.
- void ReleaseTransportDIB(TransportDIB* memory);
+ virtual void ReleaseTransportDIB(TransportDIB* memory) = 0;
- // Returns true if plugins should be loaded in-process.
- bool in_process_plugins() const { return in_process_plugins_; }
+ // Returns true if plugisn should be loaded in-process.
+ virtual bool UseInProcessPlugins() const = 0;
- bool initialized_media_library() const { return initialized_media_library_; }
+ virtual bool HasInitializedMediaLibrary() const = 0;
- // Returns a pointer to the RenderProcess singleton instance.
+ // Returns a pointer to the RenderProcess singleton instance. Assuming that
+ // we're actually a renderer or a renderer test, this static cast will
+ // be correct.
static RenderProcess* current() {
return static_cast<RenderProcess*>(ChildProcess::current());
}
- // Just like in_process_plugins(), but called before RenderProcess is created.
- static bool InProcessPlugins();
-
- // Sends a message to the browser process asking to launch a new NaCl process.
- // Called from NaCl plugin code.
- static bool LaunchNaClProcess(const char* url,
- int imc_fd,
- nacl::Handle* imc_handle,
- nacl::Handle* nacl_process_handle,
- int* nacl_process_id);
-
private:
- // Look in the shared memory cache for a suitable object to reuse.
- // result: (output) the memory found
- // size: the resulting memory will be >= this size, in bytes
- // returns: false if a suitable DIB memory could not be found
- bool GetTransportDIBFromCache(TransportDIB** result, 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(TransportDIB* memory);
-
- void ClearTransportDIBCache();
-
- // Return the index of a free cache slot in which to install a transport DIB
- // of the given size. If all entries in the cache are larger than the given
- // size, this doesn't free any slots and returns -1.
- int FindFreeCacheSlot(size_t size);
-
- // Create a new transport DIB of, at least, the given size. Return NULL on
- // error.
- TransportDIB* CreateTransportDIB(size_t size);
- void FreeTransportDIB(TransportDIB*);
-
- // 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.
- TransportDIB* shared_mem_cache_[2];
-
- // This DelayTimer cleans up our cache 5 seconds after the last use.
- base::DelayTimer<RenderProcess> shared_mem_cache_cleaner_;
-
- // TransportDIB sequence number
- uint32 sequence_number_;
-
- bool in_process_plugins_;
- bool initialized_media_library_;
-
DISALLOW_COPY_AND_ASSIGN(RenderProcess);
};
-#endif // CHROME_RENDERER_RENDER_PROCESS_H__
+#endif // CHROME_RENDERER_RENDER_PROCESS_H_