Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: content/browser/background_fetch/background_fetch_data_manager.h

Issue 2678273003: Initial framework setup and skeleton for BackgroundFetchContext (Closed)
Patch Set: Removed unused browser_context_ stored member. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/background_fetch/background_fetch_data_manager.h
diff --git a/content/browser/background_fetch/background_fetch_data_manager.h b/content/browser/background_fetch/background_fetch_data_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..3244a5556bbee2716813fd61dae52e967c9a644f
--- /dev/null
+++ b/content/browser/background_fetch/background_fetch_data_manager.h
@@ -0,0 +1,48 @@
+// Copyright 2017 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_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_
+#define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_
+
+#include <map>
+#include <string>
+
+#include "base/macros.h"
+#include "content/browser/background_fetch/fetch_request.h"
+#include "content/common/content_export.h"
+#include "url/origin.h"
+
+namespace content {
+
+class BackgroundFetchContext;
+
+// The BackgroundFetchDataManager keeps track of all of the outstanding requests
+// which are in process in the DownloadManager. When Chromium restarts, it is
+// responsibile for reconnecting all the in progress downloads with an observer
+// which will keep the metadata up to date.
+class CONTENT_EXPORT BackgroundFetchDataManager {
+ public:
+ explicit BackgroundFetchDataManager(
+ BackgroundFetchContext* background_fetch_context);
+ ~BackgroundFetchDataManager();
+
+ // Called by BackgroundFetchContext when a new request is started, this will
+ // store all of the necessary metadata to track the request.
+ void CreateRequest(const FetchRequest& fetch_request);
+
+ private:
+ // BackgroundFetchContext owns this BackgroundFetchDataManager, so the
+ // DataManager is guaranteed to be destructed before the Context.
+ BackgroundFetchContext* background_fetch_context_;
+
+ // Map from <sw_registration_id, tag> to the FetchRequest for that tag.
+ using FetchIdentifier = std::pair<int64_t, std::string>;
+ std::map<FetchIdentifier, FetchRequest> fetch_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698