| Index: chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h
|
| diff --git a/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h b/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..006e2125b938057a684245029199984ca7007098
|
| --- /dev/null
|
| +++ b/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h
|
| @@ -0,0 +1,75 @@
|
| +// Copyright 2016 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_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_
|
| +#define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_
|
| +
|
| +#include "base/macros.h"
|
| +#include "components/keyed_service/core/keyed_service.h"
|
| +
|
| +class IOThread;
|
| +
|
| +namespace content {
|
| +class NavigationHandle;
|
| +class RenderFrameHost;
|
| +}
|
| +
|
| +namespace data_use_measurement {
|
| +class ChromeDataUseAscriber;
|
| +
|
| +// UI thread functionality of ChromeDataUseAscriber.
|
| +//
|
| +// Listens to navigation and frame events on the UI thread and propagates them
|
| +// to ChromeDataUseAscriber on the IO thread. This class depends on external
|
| +// WebContentsObservers to propagate events to itself because each
|
| +// WebContents instance requires its own WebContentsObserver instance.
|
| +//
|
| +// Created and destroyed on the UI thread. Public methods should only be called
|
| +// on the UI thread.
|
| +class ChromeDataUseAscriberService : public KeyedService {
|
| + public:
|
| + ChromeDataUseAscriberService();
|
| + ~ChromeDataUseAscriberService() override;
|
| +
|
| + // Called when a render frame host is created. Propagates this information to
|
| + // |ascriber_| on the IO thread. |RenderFrameHost| methods cannot be called
|
| + // on the IO thread, so only routing IDs of |render_frame_host| and its parent
|
| + // are propagated.
|
| + void RenderFrameCreated(content::RenderFrameHost* render_frame_host);
|
| +
|
| + // Called when a render frame host is deleted. Propagates this information to
|
| + // |ascriber_| on the IO thread. RenderFrameHost methods cannot be called
|
| + // on the IO thread, so only routing IDs of |render_frame_host| and its parent
|
| + // are propagated.
|
| + void RenderFrameDeleted(content::RenderFrameHost* render_frame_host);
|
| +
|
| + // Called when a navigation is started. Propagates main frame navigation
|
| + // start to the |ascriber_| on the IO thread. NavigationHandle methods
|
| + // cannot be called on the IO thread, so the pointer is cast to void*.
|
| + void DidStartNavigation(content::NavigationHandle* navigation_handle);
|
| +
|
| + // Called when a navigation is finished. Propagates main frame navigation
|
| + // finish to the |ascriber_| on the IO thread. NavigationHandle methods
|
| + // cannot be called on the IO thread, so the pointer is cast to void*.
|
| + void DidFinishNavigation(content::NavigationHandle* navigation_handle);
|
| +
|
| + // Called when a navigation is redirected. Propagates main frame navigation
|
| + // redirect to the |ascriber_| on the IO thread. NavigationHandle methods
|
| + // cannot be called on the IO thread, so the pointer is cast to void*.
|
| + void DidRedirectNavigation(content::NavigationHandle* navigation_handle);
|
| +
|
| + private:
|
| + friend class ChromeDataUseAscriberServiceTest;
|
| +
|
| + void SetDataUseAscriber(ChromeDataUseAscriber* ascriber);
|
| +
|
| + // |ascriber_| outlives this instance.
|
| + ChromeDataUseAscriber* ascriber_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriberService);
|
| +};
|
| +
|
| +} // namespace data_use_measurement
|
| +
|
| +#endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_SERVICE_H_
|
|
|