{"action":"created","comment":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/174616234","pull_request_review_id":104006309,"id":174616234,"diff_hunk":"@@ -0,0 +1,233 @@\n+/**\n+ * Copyright 2018 The AMP HTML Authors. All Rights Reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS-IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+import {\n+  FailureType,\n+  RecoveryModeType,\n+} from './amp-ad-type-defs';\n+import {Services} from '../../../src/services';\n+import {dev} from '../../../src/log';\n+import {isLayoutSizeDefined} from '../../../src/layout';\n+import {map} from '../../../src/utils/object';\n+import {sendXhrRequest} from './amp-ad-utils';\n+\n+const TAG = 'amp-ad-network-base';\n+\n+/**\n+ * @abstract\n+ */\n+export class AmpAdNetworkBase extends AMP.BaseElement {\n+\n+  constructor(element) {\n+    super(element);\n+\n+    /** @private {?Promise<!../../../src/service/xhr-impl.FetchResponse>} */\n+    this.adPromise_ = null;\n+\n+    /** @private {Object<string, !./amp-ad-type-defs.Validator>} */\n+    this.validators_ = map();\n+\n+    /** @private {Object<string, !./amp-ad-type-defs.Renderer>} */\n+    this.renderers_ = map();\n+\n+    /** @private {Object<string, string>} */\n+    this.recoveryModes_ = map();\n+\n+    /** @private {?./amp-ad-type-defs.LayoutInfoDef} */\n+    this.initialSize_ = null;\n+\n+    /** @const @private {!Object} */\n+    this.context_ = {};\n+\n+    // Register default error modes.\n+    for (const failureType in FailureType) {\n+      this.recoveryModes_[failureType] = RecoveryModeType.COLLAPSE;\n+    }\n+\n+    /**\n+     * Number of times to retry a failed request. Zero by default.\n+     * @type {number}\n+     */\n+    this.retryLimit_ = 0;\n+  }\n+\n+  /** @override */\n+  buildCallback() {\n+    this.initialSize_ = {\n+      // TODO(levitzky) handle non-numeric values.\n+      width: this.element.getAttribute('width'),\n+      height: this.element.getAttribute('height'),\n+    };\n+  }\n+\n+  /** @override */\n+  isLayoutSupported(layout) {\n+    return isLayoutSizeDefined(layout);\n+  }\n+\n+  /** @override */\n+  layoutCallback() {\n+    dev().assert(this.adPromise_, 'layoutCallback invoked before XHR request!');\n+    return this.adPromise_\n+        .then(response => this.invokeValidator_(response))\n+        .then(validatorResult => this.invokeRenderer_(validatorResult))\n+        .catch(error => this.handleFailure_(error.type, error.msg));\n+  }\n+\n+  /** @override */\n+  onLayoutMeasure() {\n+    this.sendRequest_();\n+  }\n+\n+\n+  /**\n+   * @param {!./amp-ad-type-defs.FailureType} failure\n+   * @param {!./amp-ad-type-defs.RecoveryModeType} recovery\n+   * @final\n+   */\n+  onFailure(failure, recovery) {\n+    if (this.recoveryModes_[failure]) {\n+      dev().warn(TAG,\n+          `Recovery mode for failure type ${failure} already registered!`);\n+    }\n+    this.recoveryModes_[failure] = recovery;\n+  }\n+\n+  /**\n+   * @param {!./amp-ad-type-defs.Validator} validator\n+   * @param {string=} type\n+   * @final\n+   */\n+  registerValidator(validator, type = 'default') {\n+    if (this.validators_[type]) {\n+      dev().warn(TAG, `${type} validator already registered.`);\n+    }\n+    this.validators_[type] = validator;\n+  }\n+\n+  /**\n+   * @param {!./amp-ad-type-defs.Renderer} renderer\n+   * @param {string} type\n+   * @final\n+   */\n+  registerRenderer(renderer, type) {\n+    if (this.renderers_[type]) {\n+      dev().warn(TAG, `Rendering mode already registered for type '${type}'`);\n+    }\n+    this.renderers_[type] = renderer;\n+  }\n+\n+  /**\n+   * @param {string} name\n+   * @param {*} value\n+   */\n+  setContextField(name, value) {","path":"extensions/amp-ad-network-base/0.1/amp-ad-network-base.js","position":null,"original_position":137,"commit_id":"40294e49743e912c3a9844341907df677d2fe464","original_commit_id":"cb12fe36683c1aaad574b370cd4f413feaf265e4","user":{"login":"glevitzky","id":20518281,"avatar_url":"https://avatars1.githubusercontent.com/u/20518281?v=4","gravatar_id":"","url":"https://api.github.com/users/glevitzky","html_url":"https://github.com/glevitzky","followers_url":"https://api.github.com/users/glevitzky/followers","following_url":"https://api.github.com/users/glevitzky/following{/other_user}","gists_url":"https://api.github.com/users/glevitzky/gists{/gist_id}","starred_url":"https://api.github.com/users/glevitzky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glevitzky/subscriptions","organizations_url":"https://api.github.com/users/glevitzky/orgs","repos_url":"https://api.github.com/users/glevitzky/repos","events_url":"https://api.github.com/users/glevitzky/events{/privacy}","received_events_url":"https://api.github.com/users/glevitzky/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2018-03-14T21:30:28Z","updated_at":"2018-03-14T21:30:28Z","html_url":"https://github.com/ampproject/amphtml/pull/13675#discussion_r174616234","pull_request_url":"https://api.github.com/repos/ampproject/amphtml/pulls/13675","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/174616234"},"html":{"href":"https://github.com/ampproject/amphtml/pull/13675#discussion_r174616234"},"pull_request":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/13675"}},"in_reply_to_id":174529369},"pull_request":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/13675","id":171485532,"html_url":"https://github.com/ampproject/amphtml/pull/13675","diff_url":"https://github.com/ampproject/amphtml/pull/13675.diff","patch_url":"https://github.com/ampproject/amphtml/pull/13675.patch","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/13675","number":13675,"state":"open","locked":false,"title":"Introduces amp-ad-base, an abstract, lightweight, alternative to amp-a4a.","user":{"login":"glevitzky","id":20518281,"avatar_url":"https://avatars1.githubusercontent.com/u/20518281?v=4","gravatar_id":"","url":"https://api.github.com/users/glevitzky","html_url":"https://github.com/glevitzky","followers_url":"https://api.github.com/users/glevitzky/followers","following_url":"https://api.github.com/users/glevitzky/following{/other_user}","gists_url":"https://api.github.com/users/glevitzky/gists{/gist_id}","starred_url":"https://api.github.com/users/glevitzky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glevitzky/subscriptions","organizations_url":"https://api.github.com/users/glevitzky/orgs","repos_url":"https://api.github.com/users/glevitzky/repos","events_url":"https://api.github.com/users/glevitzky/events{/privacy}","received_events_url":"https://api.github.com/users/glevitzky/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-26T20:40:22Z","updated_at":"2018-03-14T21:30:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52ad0065635bdcc453e0ce376eb5a7e1d6f52895","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":596633554,"url":"https://api.github.com/repos/ampproject/amphtml/labels/cla:%20yes","name":"cla: yes","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ampproject/amphtml/pulls/13675/commits","review_comments_url":"https://api.github.com/repos/ampproject/amphtml/pulls/13675/comments","review_comment_url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/13675/comments","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/40294e49743e912c3a9844341907df677d2fe464","head":{"label":"glevitzky:ampadbase","ref":"ampadbase","sha":"40294e49743e912c3a9844341907df677d2fe464","user":{"login":"glevitzky","id":20518281,"avatar_url":"https://avatars1.githubusercontent.com/u/20518281?v=4","gravatar_id":"","url":"https://api.github.com/users/glevitzky","html_url":"https://github.com/glevitzky","followers_url":"https://api.github.com/users/glevitzky/followers","following_url":"https://api.github.com/users/glevitzky/following{/other_user}","gists_url":"https://api.github.com/users/glevitzky/gists{/gist_id}","starred_url":"https://api.github.com/users/glevitzky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glevitzky/subscriptions","organizations_url":"https://api.github.com/users/glevitzky/orgs","repos_url":"https://api.github.com/users/glevitzky/repos","events_url":"https://api.github.com/users/glevitzky/events{/privacy}","received_events_url":"https://api.github.com/users/glevitzky/received_events","type":"User","site_admin":false},"repo":{"id":107138995,"name":"amphtml","full_name":"glevitzky/amphtml","owner":{"login":"glevitzky","id":20518281,"avatar_url":"https://avatars1.githubusercontent.com/u/20518281?v=4","gravatar_id":"","url":"https://api.github.com/users/glevitzky","html_url":"https://github.com/glevitzky","followers_url":"https://api.github.com/users/glevitzky/followers","following_url":"https://api.github.com/users/glevitzky/following{/other_user}","gists_url":"https://api.github.com/users/glevitzky/gists{/gist_id}","starred_url":"https://api.github.com/users/glevitzky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glevitzky/subscriptions","organizations_url":"https://api.github.com/users/glevitzky/orgs","repos_url":"https://api.github.com/users/glevitzky/repos","events_url":"https://api.github.com/users/glevitzky/events{/privacy}","received_events_url":"https://api.github.com/users/glevitzky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/glevitzky/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":true,"url":"https://api.github.com/repos/glevitzky/amphtml","forks_url":"https://api.github.com/repos/glevitzky/amphtml/forks","keys_url":"https://api.github.com/repos/glevitzky/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/glevitzky/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/glevitzky/amphtml/teams","hooks_url":"https://api.github.com/repos/glevitzky/amphtml/hooks","issue_events_url":"https://api.github.com/repos/glevitzky/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/glevitzky/amphtml/events","assignees_url":"https://api.github.com/repos/glevitzky/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/glevitzky/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/glevitzky/amphtml/tags","blobs_url":"https://api.github.com/repos/glevitzky/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/glevitzky/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/glevitzky/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/glevitzky/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/glevitzky/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/glevitzky/amphtml/languages","stargazers_url":"https://api.github.com/repos/glevitzky/amphtml/stargazers","contributors_url":"https://api.github.com/repos/glevitzky/amphtml/contributors","subscribers_url":"https://api.github.com/repos/glevitzky/amphtml/subscribers","subscription_url":"https://api.github.com/repos/glevitzky/amphtml/subscription","commits_url":"https://api.github.com/repos/glevitzky/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/glevitzky/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/glevitzky/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/glevitzky/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/glevitzky/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/glevitzky/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/glevitzky/amphtml/merges","archive_url":"https://api.github.com/repos/glevitzky/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/glevitzky/amphtml/downloads","issues_url":"https://api.github.com/repos/glevitzky/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/glevitzky/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/glevitzky/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/glevitzky/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/glevitzky/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/glevitzky/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/glevitzky/amphtml/deployments","created_at":"2017-10-16T14:29:01Z","updated_at":"2017-10-16T14:29:15Z","pushed_at":"2018-03-14T21:17:17Z","git_url":"git://github.com/glevitzky/amphtml.git","ssh_url":"git@github.com:glevitzky/amphtml.git","clone_url":"https://github.com/glevitzky/amphtml.git","svn_url":"https://github.com/glevitzky/amphtml","homepage":"https://www.ampproject.org","size":411798,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ampproject:master","ref":"master","sha":"446465a6b37fcdac487aeab8b1e421246bcb8eba","user":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars3.githubusercontent.com/u/14114390?v=4","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"repo":{"id":41766002,"name":"amphtml","full_name":"ampproject/amphtml","owner":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars3.githubusercontent.com/u/14114390?v=4","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ampproject/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":false,"url":"https://api.github.com/repos/ampproject/amphtml","forks_url":"https://api.github.com/repos/ampproject/amphtml/forks","keys_url":"https://api.github.com/repos/ampproject/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ampproject/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ampproject/amphtml/teams","hooks_url":"https://api.github.com/repos/ampproject/amphtml/hooks","issue_events_url":"https://api.github.com/repos/ampproject/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/ampproject/amphtml/events","assignees_url":"https://api.github.com/repos/ampproject/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/ampproject/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/ampproject/amphtml/tags","blobs_url":"https://api.github.com/repos/ampproject/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ampproject/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ampproject/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/ampproject/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/ampproject/amphtml/languages","stargazers_url":"https://api.github.com/repos/ampproject/amphtml/stargazers","contributors_url":"https://api.github.com/repos/ampproject/amphtml/contributors","subscribers_url":"https://api.github.com/repos/ampproject/amphtml/subscribers","subscription_url":"https://api.github.com/repos/ampproject/amphtml/subscription","commits_url":"https://api.github.com/repos/ampproject/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/ampproject/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/ampproject/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/ampproject/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/ampproject/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/ampproject/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ampproject/amphtml/merges","archive_url":"https://api.github.com/repos/ampproject/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ampproject/amphtml/downloads","issues_url":"https://api.github.com/repos/ampproject/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/ampproject/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/ampproject/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/ampproject/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ampproject/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/ampproject/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/ampproject/amphtml/deployments","created_at":"2015-09-01T22:10:53Z","updated_at":"2018-03-14T21:17:05Z","pushed_at":"2018-03-14T21:17:19Z","git_url":"git://github.com/ampproject/amphtml.git","ssh_url":"git@github.com:ampproject/amphtml.git","clone_url":"https://github.com/ampproject/amphtml.git","svn_url":"https://github.com/ampproject/amphtml","homepage":"https://www.ampproject.org","size":413218,"stargazers_count":11300,"watchers_count":11300,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":2286,"mirror_url":null,"archived":false,"open_issues_count":1176,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2286,"open_issues":1176,"watchers":11300,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/13675"},"html":{"href":"https://github.com/ampproject/amphtml/pull/13675"},"issue":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/13675"},"comments":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/13675/comments"},"review_comments":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/13675/comments"},"review_comment":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/13675/commits"},"statuses":{"href":"https://api.github.com/repos/ampproject/amphtml/statuses/40294e49743e912c3a9844341907df677d2fe464"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"glevitzky"}}