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

Side by Side Diff: components/offline_pages/core/downloads/download_ui_adapter.cc

Issue 2716013003: Fixes to enable indication of bytes downloaded for Offline Pages in Download Home. (Closed)
Patch Set: fix build break 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
« no previous file with comments | « components/offline_pages/core/downloads/download_ui_adapter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/offline_pages/core/downloads/download_ui_adapter.h" 5 #include "components/offline_pages/core/downloads/download_ui_adapter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "components/offline_pages/core/background/request_coordinator.h" 12 #include "components/offline_pages/core/background/request_coordinator.h"
13 #include "components/offline_pages/core/background/save_page_request.h" 13 #include "components/offline_pages/core/background/save_page_request.h"
14 #include "components/offline_pages/core/client_namespace_constants.h" 14 #include "components/offline_pages/core/client_namespace_constants.h"
15 #include "components/offline_pages/core/client_policy_controller.h" 15 #include "components/offline_pages/core/client_policy_controller.h"
16 #include "components/offline_pages/core/downloads/download_ui_item.h" 16 #include "components/offline_pages/core/downloads/download_ui_item.h"
17 #include "components/offline_pages/core/offline_page_model.h" 17 #include "components/offline_pages/core/offline_page_model.h"
18 18
19 namespace {
20 // Value of this constant doesn't matter, only its address is used.
21 const char kDownloadUIAdapterKey[] = "";
22 }
23
19 namespace offline_pages { 24 namespace offline_pages {
20 25
26 // static
27 DownloadUIAdapter* DownloadUIAdapter::FromOfflinePageModel(
28 OfflinePageModel* model) {
29 DCHECK(model);
30 return static_cast<DownloadUIAdapter*>(
31 model->GetUserData(kDownloadUIAdapterKey));
32 }
33
34 // static
35 void DownloadUIAdapter::AttachToOfflinePageModel(DownloadUIAdapter* adapter,
36 OfflinePageModel* model) {
37 DCHECK(adapter);
38 DCHECK(model);
39 model->SetUserData(kDownloadUIAdapterKey, adapter);
40 }
41
21 DownloadUIAdapter::ItemInfo::ItemInfo(const OfflinePageItem& page) 42 DownloadUIAdapter::ItemInfo::ItemInfo(const OfflinePageItem& page)
22 : ui_item(base::MakeUnique<DownloadUIItem>(page)), 43 : ui_item(base::MakeUnique<DownloadUIItem>(page)),
23 is_request(false), 44 is_request(false),
24 offline_id(page.offline_id), 45 offline_id(page.offline_id),
25 client_id(page.client_id), 46 client_id(page.client_id),
26 temporarily_hidden(false) {} 47 temporarily_hidden(false) {}
27 48
28 DownloadUIAdapter::ItemInfo::ItemInfo(const SavePageRequest& request) 49 DownloadUIAdapter::ItemInfo::ItemInfo(const SavePageRequest& request)
29 : ui_item(base::MakeUnique<DownloadUIItem>(request)), 50 : ui_item(base::MakeUnique<DownloadUIItem>(request)),
30 is_request(true), 51 is_request(true),
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 items_.erase(it); 338 items_.erase(it);
318 339
319 if (state_ != State::LOADED) 340 if (state_ != State::LOADED)
320 return; 341 return;
321 342
322 for (Observer& observer : observers_) 343 for (Observer& observer : observers_)
323 observer.ItemDeleted(guid); 344 observer.ItemDeleted(guid);
324 } 345 }
325 346
326 } // namespace offline_pages 347 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/core/downloads/download_ui_adapter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698