Chromium Code Reviews| Index: components/offline_pages/core/prefetch/prefetch_types.h |
| diff --git a/components/offline_pages/core/prefetch/prefetch_types.h b/components/offline_pages/core/prefetch/prefetch_types.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dee572099adb9566570a2e6f29d9da157ff9c7c1 |
| --- /dev/null |
| +++ b/components/offline_pages/core/prefetch/prefetch_types.h |
| @@ -0,0 +1,65 @@ |
| +// 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 COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_TYPES_H_ |
| +#define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_TYPES_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/time/time.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| + |
| +namespace offline_pages { |
| + |
| +// Status for sending prefetch request to the server. |
| +enum class RequestStatus { |
|
dewittj
2017/05/11 18:46:43
This is too generic a name, I think. PrefetchRequ
jianli
2017/05/11 20:45:14
Changed to PrefetchRequestStatus. This enum is use
|
| + // Request completed successfully. |
| + SUCCESS, |
| + // Request failed due to to local network problem, unrelated to server load |
| + // levels. The caller will simply reschedule the retry in the next available |
| + // WiFi window after 15 minutes have passed. |
| + SHOULD_RETRY_WITHOUT_BACKOFF, |
| + // Request failed probably related to transient server problems. The caller |
| + // will reschedule the retry with backoff included. |
| + SHOULD_RETRY_WITH_BACKOFF, |
| + // Request failed with error indicating that the server no longer knows how |
| + // to service a request. The caller will prevent network requests for the |
| + // period of 1 day. |
| + SHOULD_SUSPEND |
| +}; |
| + |
| +// Status indicating the page rendering status in the server. |
| +enum class RenderStatus { |
| + // The page is rendered. |
| + RENDERED, |
| + // The page is still being processed. |
| + PENDING_TO_RENDER, |
|
dewittj
2017/05/11 18:46:43
nit: PENDING
jianli
2017/05/11 20:45:14
Done.
|
| + // The page failed to render. |
| + FAILED_TO_RENDER, |
|
dewittj
2017/05/11 18:46:43
nit: FAILED
jianli
2017/05/11 20:45:14
Done.
|
| + // Failed due to bundle size limits. |
| + EXCEEDED_LIMIT |
| +}; |
| + |
| +struct PageInfo { |
| + PageInfo() : status(RenderStatus::FAILED_TO_RENDER), body_length(0) {} |
|
dewittj
2017/05/11 18:46:43
nit: remove constructor, use:
RenderStatus staus
jianli
2017/05/11 20:45:14
Moved initialization to in place.
I can't remove
|
| + |
| + // The URL of the page that was rendered. |
| + std::string url; |
| + // The final URL after redirects. Empty if the final URL is url. |
| + std::string redirect_url; |
| + // Status of the render attempt. |
| + RenderStatus status; |
| + // Resource name for the body which can be read via the ByteStream API. |
| + // Set only when |status| is RENDERED. |
| + std::string body_name; |
| + // Length of the body in bytes. Set only when |status| is RENDERED. |
| + int64_t body_length; |
| + // Time the page was rendered. |
| + base::Time render_time; |
| +}; |
| + |
| +} // namespace offline_pages |
| + |
| +#endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_TYPES_H_ |