OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "content/browser/background_fetch/background_fetch_context.h" | 5 #include "content/browser/background_fetch/background_fetch_context.h" |
6 | 6 |
7 #include "content/browser/background_fetch/background_fetch_job_info.h" | 7 #include "content/browser/background_fetch/background_fetch_job_info.h" |
8 #include "content/browser/background_fetch/background_fetch_request_info.h" | 8 #include "content/browser/background_fetch/background_fetch_request_info.h" |
9 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 // Inform the data manager about the new download. | 61 // Inform the data manager about the new download. |
62 std::unique_ptr<BackgroundFetchJobData> job_data = | 62 std::unique_ptr<BackgroundFetchJobData> job_data = |
63 background_fetch_data_manager_.CreateRequest(job_info, request_infos); | 63 background_fetch_data_manager_.CreateRequest(job_info, request_infos); |
64 | 64 |
65 // If job_data is null, the DataManager will have logged an error. | 65 // If job_data is null, the DataManager will have logged an error. |
66 if (job_data) { | 66 if (job_data) { |
67 // Create a controller which drives the processing of the job. It will use | 67 // Create a controller which drives the processing of the job. It will use |
68 // the JobData to get information about individual requests for the job. | 68 // the JobData to get information about individual requests for the job. |
69 job_map_[job_info.guid()] = base::MakeUnique<BackgroundFetchJobController>( | 69 job_map_[job_info.guid()] = base::MakeUnique<BackgroundFetchJobController>( |
70 job_info.guid(), browser_context_, storage_partition_, | 70 job_info.guid(), browser_context_, storage_partition_, |
71 std::move(job_data)); | 71 std::move(job_data), |
72 base::Bind(&BackgroundFetchContext::JobComplete, this, | |
73 job_info.guid())); | |
Peter Beverloo
2017/03/15 16:53:38
We need to clear job_map_ in ShutdownOnIO. This cr
harkness
2017/03/16 11:41:09
Done.
| |
72 } | 74 } |
73 } | 75 } |
74 | 76 |
77 void BackgroundFetchContext::JobComplete(const std::string& job_guid) { | |
78 DCHECK(job_map_.find(job_guid) != job_map_.end()); | |
79 | |
80 // TODO(harkness): Get enough data to send the response back to the | |
81 // caller. | |
Peter Beverloo
2017/03/15 16:53:38
micro nit: same re: the TODO
harkness
2017/03/16 11:41:09
Done.
| |
82 | |
83 job_map_.erase(job_guid); | |
84 | |
85 // TODO(harkness): Once the caller receives the message, inform the | |
86 // DataManager that it can clean up the pending job. | |
87 } | |
88 | |
75 } // namespace content | 89 } // namespace content |
OLD | NEW |