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

Side by Side Diff: chrome/browser/android/offline_pages/prerendering_offliner.h

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Approach for writing to the file afterwards instead. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/android/application_status_listener.h" 10 #include "base/android/application_status_listener.h"
11 #include "base/files/file_path.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/android/offline_pages/prerendering_loader.h" 13 #include "chrome/browser/android/offline_pages/prerendering_loader.h"
13 #include "components/offline_pages/core/background/offliner.h" 14 #include "components/offline_pages/core/background/offliner.h"
14 #include "components/offline_pages/core/offline_page_model.h" 15 #include "components/offline_pages/core/offline_page_model.h"
15 #include "components/offline_pages/core/offline_page_types.h" 16 #include "components/offline_pages/core/offline_page_types.h"
16 17
17 namespace content { 18 namespace content {
18 class BrowserContext; 19 class BrowserContext;
19 class WebContents; 20 class WebContents;
20 } // namespace content 21 } // namespace content
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void OnNetworkProgress(const SavePageRequest& request, int64_t bytes); 63 void OnNetworkProgress(const SavePageRequest& request, int64_t bytes);
63 64
64 // Callback logic for PrerenderingLoader::LoadPage(). 65 // Callback logic for PrerenderingLoader::LoadPage().
65 void OnLoadPageDone(const SavePageRequest& request, 66 void OnLoadPageDone(const SavePageRequest& request,
66 Offliner::RequestStatus load_status, 67 Offliner::RequestStatus load_status,
67 content::WebContents* web_contents); 68 content::WebContents* web_contents);
68 69
69 // Callback logic for OfflinePageModel::SavePage(). 70 // Callback logic for OfflinePageModel::SavePage().
70 void OnSavePageDone(const SavePageRequest& request, 71 void OnSavePageDone(const SavePageRequest& request,
71 SavePageResult save_result, 72 SavePageResult save_result,
72 int64_t offline_id); 73 int64_t offline_id,
74 const base::FilePath& saved_filepath);
73 75
74 PrerenderingLoader* GetOrCreateLoader(); 76 PrerenderingLoader* GetOrCreateLoader();
75 77
76 // Listener function for changes to application background/foreground state. 78 // Listener function for changes to application background/foreground state.
77 void OnApplicationStateChange( 79 void OnApplicationStateChange(
78 base::android::ApplicationState application_state); 80 base::android::ApplicationState application_state);
79 81
82 // Transfer over to the FileThread, and call AppendSignalData from there.
83 void AppendSignalDataOnFileThread(const base::FilePath& file_path);
84
85 // Add signal data to the end of the MHTML file.
86 void AppendSignalData(const base::FilePath& filename);
87
88 // TODO: Find a standard function to replace this with.
fgorski 2017/03/08 18:56:43 std::isspace ?
89 static bool IsWhitespace(char next);
90
91 // Return the file position just before the two dashes.
92 static int64_t PositionBeforeTwoDashes(base::File& saved_file);
93
94 // Parse the boundary string from a MHTML file
95 static std::string GetBoundaryStringFromFile(base::File& saved_file);
96
80 // Not owned. 97 // Not owned.
81 content::BrowserContext* browser_context_; 98 content::BrowserContext* browser_context_;
82 // Not owned. 99 // Not owned.
83 const OfflinerPolicy* policy_; 100 const OfflinerPolicy* policy_;
84 // Not owned. 101 // Not owned.
85 OfflinePageModel* offline_page_model_; 102 OfflinePageModel* offline_page_model_;
86 // Lazily created. 103 // Lazily created.
87 std::unique_ptr<PrerenderingLoader> loader_; 104 std::unique_ptr<PrerenderingLoader> loader_;
88 // Tracks pending request, if any. Owned copy. 105 // Tracks pending request, if any. Owned copy.
89 // May be used to ensure a callback applies to the pending request (e.g., in 106 // May be used to ensure a callback applies to the pending request (e.g., in
90 // case we receive a save page callback for an old, canceled request). 107 // case we receive a save page callback for an old, canceled request).
91 std::unique_ptr<SavePageRequest> pending_request_; 108 std::unique_ptr<SavePageRequest> pending_request_;
92 // Callback to call when pending request completes/fails. 109 // Callback to call when pending request completes/fails.
93 CompletionCallback completion_callback_; 110 CompletionCallback completion_callback_;
94 bool is_low_end_device_; 111 bool is_low_end_device_;
95 // ApplicationStatusListener to monitor if the Chrome moves to the foreground. 112 // ApplicationStatusListener to monitor if the Chrome moves to the foreground.
96 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; 113 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_;
97 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_; 114 base::WeakPtrFactory<PrerenderingOffliner> weak_ptr_factory_;
98 115
99 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner); 116 DISALLOW_COPY_AND_ASSIGN(PrerenderingOffliner);
100 }; 117 };
101 118
102 } // namespace offline_pages 119 } // namespace offline_pages
103 120
104 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_ 121 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698