正在加载图片...
A browser kernel in Google Chrome #include <iostream> 27 void tab_request_handler_loop(void){ 2 #include <stdio.h> Shell*sh NULL; 3 #define SMALL SCREEN 1 /1 or 0 2 Window*win SMALL SCREEN new Mobilewin():new Window(); 4 //run a command while (true){ 5 class Shell 3 TabRequest r=recv_tab_request(); 2 switch (r.kind) 6 f case GET DATE: 7 public: 34 if (sh =NULL) 8 virtual void run(const char *cmd){ sh new Shell(); 9 system(cmd); 3 /run shell with safe,const string 10 string d sh->run("date"); 3 send tab response(r.originating_tab,d); 1 7/for displaying content on screen break; 48 case DISPLAY ALERT: class Window win->display(r.msg); 14 /If the object that win points to was accidentally 1 public:virtual void display(const char *s){ /deleted,and a Shell object was allocated in its 16 printf("%s\n",s)月 /place,then the above call invokes method 0 of 17 11 Shell via the dangling win ptr,namely "run"with 1 } /a tab-controlled arg! /specialized for small screens on mobile devices 1 break; 29 class Mobilewin public Window case GET HTML: 49 /BUG:accidental delete,win ptr now dangling public: delete win; virtual void display(const char *s){ 552 24 printf("%s\n",s); break; 5545 } 6 18A browser kernel in Google Chrome 18
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有