Skip to content

Commit

Permalink
add h2 pushed requests artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Sep 14, 2016
1 parent 134caf4 commit fc11e0a
Show file tree
Hide file tree
Showing 3 changed files with 20,419 additions and 0 deletions.
46 changes: 46 additions & 0 deletions lighthouse-core/gather/computed/pushed-requests.js
@@ -0,0 +1,46 @@
/**
* @license
* Copyright 2016 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

const ComputedArtifact = require('./computed-artifact');

class PushedRequests extends ComputedArtifact {

get name() {
return 'PushedRequests';
}

filterPushed(records) {
const pushedRecords = records.filter(r => r._timing && !!r._timing.pushStart);
return Promise.resolve(pushedRecords);
}

request(networkRecords) {
if (this.cache.has(networkRecords)) {
return this.cache.get(networkRecords);
}

return this.filterPushed(networkRecords).then(records => {
this.cache.set(records, networkRecords);
return records;
});
}

}

module.exports = PushedRequests;

0 comments on commit fc11e0a

Please sign in to comment.