| Index: content/renderer/gpu/frame_swap_message_queue.h
|
| diff --git a/content/renderer/gpu/frame_swap_message_queue.h b/content/renderer/gpu/frame_swap_message_queue.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c69dceef001f37ac59e6ca99f636dea262247d7b
|
| --- /dev/null
|
| +++ b/content/renderer/gpu/frame_swap_message_queue.h
|
| @@ -0,0 +1,94 @@
|
| +// Copyright 2014 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 CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_
|
| +#define CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_
|
| +
|
| +#include <map>
|
| +#include <vector>
|
| +
|
| +#include "base/auto_reset.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/scoped_vector.h"
|
| +#include "base/synchronization/lock.h"
|
| +#include "content/common/content_export.h"
|
| +
|
| +namespace IPC {
|
| +class Message;
|
| +};
|
| +
|
| +namespace content {
|
| +
|
| +// Queue used to keep track of which IPC::Messages should be sent along with a
|
| +// particular compositor frame swap.
|
| +class CONTENT_EXPORT FrameSwapMessageQueue
|
| + : public base::RefCountedThreadSafe<FrameSwapMessageQueue> {
|
| + public:
|
| + class CONTENT_EXPORT SendMessageScope {
|
| + public:
|
| + virtual ~SendMessageScope() {}
|
| + };
|
| +
|
| + FrameSwapMessageQueue();
|
| +
|
| + // Queues message to be returned on the next call to DrainMessages.
|
| + //
|
| + // |msg| - message to queue. The method takes ownership of |msg|.
|
| + void QueueMessage(scoped_ptr<IPC::Message> msg);
|
| +
|
| + // Queues message to be returned on the first call to DrainMessages ocurring
|
| + // after a DidSwapFrame call with the coresponding source_frame_number. Takes
|
| + // ownership of |msg|.
|
| + //
|
| + // |source_frame_number| frame number to queue |msg| for.
|
| + // |msg| - message to queue. The method takes ownership of |msg|.
|
| + // |is_first| - output parameter. Set to true if this was the first message
|
| + // enqueued for the given source_frame_number.
|
| + void QueueMessageForFrame(int source_frame_number,
|
| + scoped_ptr<IPC::Message> msg,
|
| + bool* is_first);
|
| +
|
| + // Returns true if there are no messages in the queue.
|
| + bool Empty() const;
|
| +
|
| + // Makes the next call do DrainMessages return messages scheduled for any
|
| + // source frame numbers less than or equal to |source_frame_number|.
|
| + void AdvanceToFrame(int source_frame_number);
|
| +
|
| + // A SendMessageScope object must be held by the caller when this method is
|
| + // called.
|
| + //
|
| + // |messages| vector to store messages. it's not cleared, only appended to.
|
| + // The method will append messages queued for frame numbers lower
|
| + // or equal to |source_frame_number|
|
| + void DrainMessages(ScopedVector<IPC::Message>* messages);
|
| +
|
| + // SendMessageScope is used to make sure that messages sent from different
|
| + // threads (impl/main) are scheduled in the right order on the IO threads.
|
| + //
|
| + // Returns an object that must be kept in scope till an IPC message containing
|
| + // |messages| is sent.
|
| + scoped_ptr<SendMessageScope> AcquireSendMessageScope();
|
| +
|
| + static void TransferMessages(ScopedVector<IPC::Message>& source,
|
| + std::vector<IPC::Message>* dest);
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<FrameSwapMessageQueue>;
|
| + typedef std::map<int, std::vector<IPC::Message*> > FrameQueueMap;
|
| +
|
| + ~FrameSwapMessageQueue();
|
| +
|
| + mutable base::Lock lock_;
|
| + int highest_swapped_source_frame_number_;
|
| + FrameQueueMap queued_messages_;
|
| + ScopedVector<IPC::Message> next_drain_messages_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(FrameSwapMessageQueue);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_GPU_FRAME_SWAP_MESSAGE_QUEUE_H_
|
|
|