diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-01 01:20:14 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-01 01:20:14 +0000 |
commit | 8644dfa1f63dfc3a0d01132cd1b1287dde4b29ce (patch) | |
tree | 6061b89e755dd9481ff7f4330b3b3878efc3d844 /sync/internal_api/protocol_event_buffer.h | |
parent | bb8558a3ce708090430615cb69f696c096ee8ac7 (diff) | |
download | chromium_src-8644dfa1f63dfc3a0d01132cd1b1287dde4b29ce.zip chromium_src-8644dfa1f63dfc3a0d01132cd1b1287dde4b29ce.tar.gz chromium_src-8644dfa1f63dfc3a0d01132cd1b1287dde4b29ce.tar.bz2 |
sync: Buffer Protocol Events for about:sync page
Allows the about:sync page to present the last six network events as
soon as it's opened.
Adds the ProtocolEventBuffer to the SyncManagerImpl. This class holds
on to a few protocol events and returns them on demand.
Modifies the interface to enable SyncBacknedHost protocol event
forwarding. By default, it does not forward any events. There are now
separate registration and unregistration functions. The registration
function will send the set of buffered notifications to the UI thread,
and also register it to receive incoming events in the future. It
continues to forward events until the number of registration calls is
matched by the number of un-registration calls.
Makes about:sync's registration to receive events explicit. This was
a long-time TODO. If we did not fix this issue, then the about:sync
page could receive the initial set of buffered invalidations before it
had its event listeners defined and registered.
Makes the about:sync page keep track of known events and avoid adding
duplicates to the list. Since the registration of a new event listener
causes events to be distributed to all listeners, we must add this logic
to ensure that opening one new about:sync tab will not cause previously
opened tabs to display duplicate events.
BUG=329373,349301
Review URL: https://codereview.chromium.org/212603007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/protocol_event_buffer.h')
-rw-r--r-- | sync/internal_api/protocol_event_buffer.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sync/internal_api/protocol_event_buffer.h b/sync/internal_api/protocol_event_buffer.h new file mode 100644 index 0000000..8d82210 --- /dev/null +++ b/sync/internal_api/protocol_event_buffer.h @@ -0,0 +1,42 @@ +// 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 SYNC_INTERNAL_API_PROTOCOL_EVENT_BUFFER_H_ +#define SYNC_INTERNAL_API_PROTOCOL_EVENT_BUFFER_H_ + +#include <deque> + +#include "base/memory/scoped_vector.h" +#include "sync/base/sync_export.h" + +namespace syncer { + +class ProtocolEvent; + +// A container for ProtocolEvents. +// +// Stores at most kBufferSize events, then starts dropping the oldest events. +class SYNC_EXPORT_PRIVATE ProtocolEventBuffer { + public: + static const size_t kBufferSize; + + ProtocolEventBuffer(); + ~ProtocolEventBuffer(); + + // Records an event. May cause the oldest event to be dropped. + void RecordProtocolEvent(const ProtocolEvent& event); + + // Returns the buffered contents. Will not clear the buffer. + ScopedVector<ProtocolEvent> GetBufferedProtocolEvents() const; + + private: + std::deque<ProtocolEvent*> buffer_; + STLElementDeleter<std::deque<ProtocolEvent*> > buffer_deleter_; + + DISALLOW_COPY_AND_ASSIGN(ProtocolEventBuffer); +}; + +} // namespace syncer + +#endif // SYNC_INTERNAL_API_PROTOCOL_EVENT_BUFFER_H_ |