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

Unified Diff: components/offline_pages/background/save_page_request.h

Issue 1932953002: [Offline pages] Empty RequestQueue and SavePageRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits from Pete Created 4 years, 8 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: components/offline_pages/background/save_page_request.h
diff --git a/components/offline_pages/background/save_page_request.h b/components/offline_pages/background/save_page_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..572ce318f1187b8fe43daddeaddaa0ed5874cc14
--- /dev/null
+++ b/components/offline_pages/background/save_page_request.h
@@ -0,0 +1,90 @@
+// 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 COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_
+#define COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_
+
+#include <stdint.h>
+
+#include "base/time/time.h"
+#include "components/offline_pages/offline_page_item.h"
+#include "url/gurl.h"
+
+namespace offline_pages {
+
+// Class representing a request to save page.
+class SavePageRequest {
+ public:
+ enum class Status {
+ kNotReady, // Component requested a page be saved, but not until
+ // |activation_time_|.
+ kPending, // Page request is pending, and coordinator can attempt it
+ // when it gets a chance to.
+ kStarted, // The request is currently being processed.
+ kFailed, // Page request failed many times and will no longer be
+ // retried.
+ kExpired, // Save page request expired without being fulfilled.
+ };
+
+ SavePageRequest(int64_t request_id,
+ const GURL& url,
+ const ClientId& client_id,
+ const base::Time& creation_time);
+ SavePageRequest(int64_t request_id,
+ const GURL& url,
+ const ClientId& client_id,
+ const base::Time& creation_time,
+ const base::Time& activation_time);
+ ~SavePageRequest();
+
+ // Status of this request.
+ Status GetStatus(const base::Time& now) const;
+
+ // Updates the |last_attempt_time_| and increments |attempt_count_|.
+ void MarkAttemptStarted(const base::Time& start_time);
+
+ // Marks attempt as completed and clears |last_attempt_time_|.
+ void MarkAttemptCompleted();
+
+ int64_t request_id() const { return request_id_; }
+
+ const GURL& url() const { return url_; }
+
+ const ClientId& client_id() const { return client_id_; }
+
+ const base::Time& creation_time() const { return creation_time_; }
+
+ const base::Time& activation_time() const { return activation_time_; }
+
+ int64_t attempt_count() const { return attempt_count_; }
+
+ const base::Time& last_attempt_time() const { return last_attempt_time_; }
+
+ private:
+ // ID of this request.
+ int64_t request_id_;
+
+ // Online URL of a page to be offlined.
+ GURL url_;
+
+ // Client ID related to the request. Contains namespace and ID assigned by the
+ // requester.
+ ClientId client_id_;
+
+ // Time when this request was created. (Alternative 2).
+ base::Time creation_time_;
+
+ // Time when this request will become active.
+ base::Time activation_time_;
+
+ // Number of attempts made to get the page.
+ int attempt_count_;
+
+ // Timestamp of the last request starting.
+ base::Time last_attempt_time_;
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_SAVE_PAGE_REQUEST_H_
« no previous file with comments | « components/offline_pages/background/request_queue.cc ('k') | components/offline_pages/background/save_page_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698